commit a1ca74d8062b528533a7e014bb36b97695ee0c6e
parent 70566806e4b29de8864bb902bcecdfc15c74368a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 6 Feb 2023 21:57:35 +0100
driver/posix: Add clean signal handling
Scc tends to generate too many intermediate files and
in case of signals we were not removing them. This helps
a bit in the case of signals that do not involve programming
errors.
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/cmd/cc/posix/cc.c b/src/cmd/cc/posix/cc.c
@@ -85,6 +85,13 @@ terminate(void)
}
static void
+sighandler(int sig)
+{
+ terminate();
+ _exit(1);
+}
+
+static void
addarg(int tool, char *arg)
{
struct tool *t = &tools[tool];
@@ -485,6 +492,9 @@ main(int argc, char *argv[])
int link, n;
atexit(terminate);
+ signal(SIGHUP, sighandler);
+ signal(SIGINT, sighandler);
+ signal(SIGTERM, sighandler);
if (!(arch = getenv("ARCH")))
arch = ARCH;