From 882ea80770120e4f94e98e46ef824cafc9ccfe1f Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 24 Dec 2025 13:21:17 +0100 Subject: cleantemps() fixes --- main.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main.c') diff --git a/main.c b/main.c index 2288324..eacef15 100644 --- a/main.c +++ b/main.c @@ -279,8 +279,10 @@ tempfile(const char *path, const char *ext) static int cc1(const char *out, const char *in); static const char *tempobj[countof(task.inf)], *tempout; +static pid_t rootp; static void mktemps(void) { + rootp = getpid(); for (int i = 0; i < task.ninf; ++i) { if (task.inft[i] == IFTc) tempobj[i] = tempfile(task.inf[i], "o"); @@ -288,9 +290,11 @@ mktemps(void) { if (!task.out) task.out = tempout = tempfile(task.ninf > 1 ? "run" : withext(task.inf[0], NULL), NULL); } + static void cleantemps(void) { + if (getpid() != rootp) return; for (int i = 0; i < task.ninf; ++i) { if (tempobj[i]) unlink(tempobj[i]), tempobj[i] = NULL; } @@ -330,6 +334,8 @@ compileobjs(void) if (!ccopt.dbg.any && !task.syntaxonly) { atexit(cleantemps); signal(SIGINT, sigcleantemps); + signal(SIGABRT, sigcleantemps); + signal(SIGILL, sigcleantemps); } } -- cgit v1.2.3