From 2dc6782a06eeffd9dc6b84fe93b8fcd2ce4960c7 Mon Sep 17 00:00:00 2001 From: Andrew Pinski Date: Mon, 30 Aug 2021 22:43:16 +0000 Subject: Fix PR driver/79181 (and others), not deleting some /tmp/cc* files for LTO. So the main issue here is that some signals are not setup unlike collect2. So this merges the setting up of the signal handlers to one function in collect-utils and has collect2 and lto-wrapper call that function. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: PR driver/79181 * collect-utils.c (setup_signals): New declaration. * collect-utils.h (setup_signals): New function. * collect2.c (handler): Delete. (main): Instead of manually setting up the signals, just call setup_signals. * lto-wrapper.c (main): Likewise. --- gcc/collect-utils.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'gcc/collect-utils.c') diff --git a/gcc/collect-utils.c b/gcc/collect-utils.c index 6b5d61d..19423d3 100644 --- a/gcc/collect-utils.c +++ b/gcc/collect-utils.c @@ -57,6 +57,43 @@ fatal_signal (int signum) so its normal effect occurs. */ kill (getpid (), signum); } + +/* Setup the signal handlers for the utils. */ +void +setup_signals (void) +{ +#ifdef SIGQUIT + if (signal (SIGQUIT, SIG_IGN) != SIG_IGN) + signal (SIGQUIT, fatal_signal); +#endif + if (signal (SIGINT, SIG_IGN) != SIG_IGN) + signal (SIGINT, fatal_signal); +#ifdef SIGALRM + if (signal (SIGALRM, SIG_IGN) != SIG_IGN) + signal (SIGALRM, fatal_signal); +#endif +#ifdef SIGHUP + if (signal (SIGHUP, SIG_IGN) != SIG_IGN) + signal (SIGHUP, fatal_signal); +#endif + if (signal (SIGSEGV, SIG_IGN) != SIG_IGN) + signal (SIGSEGV, fatal_signal); + if (signal (SIGTERM, SIG_IGN) != SIG_IGN) + signal (SIGTERM, fatal_signal); +#ifdef SIGPIPE + if (signal (SIGPIPE, SIG_IGN) != SIG_IGN) + signal (SIGPIPE, fatal_signal); +#endif +#ifdef SIGBUS + if (signal (SIGBUS, SIG_IGN) != SIG_IGN) + signal (SIGBUS, fatal_signal); +#endif +#ifdef SIGCHLD + /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will + receive the signal. A different setting is inheritable */ + signal (SIGCHLD, SIG_DFL); +#endif +} /* Wait for a process to finish, and exit if a nonzero status is found. */ -- cgit v1.1