diff options
| author | 2025-12-24 13:21:17 +0100 | |
|---|---|---|
| committer | 2025-12-24 13:21:17 +0100 | |
| commit | 882ea80770120e4f94e98e46ef824cafc9ccfe1f (patch) | |
| tree | 78f74ebc5a597d07ec5b1a4fb8734c5ee98db95e /main.c | |
| parent | 775ff9ce7b45c22cfba6918c13359bf89461b3e1 (diff) | |
cleantemps() fixes
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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); } } |