Improve fatal signal handling

First, we reset the signal handler back to the default one when a fatal signal
is received. This should make sure that we never get into an endless loop where
the signal handler causes the signal to happen again.

Then this commit also makes awesome print a backtrace on more signals than
before. Crashing with a backtrace is always better than without. ;-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2014-03-07 10:51:39 +01:00
parent 4717e89984
commit 202567dc12
1 changed files with 5 additions and 1 deletions

View File

@ -396,8 +396,12 @@ main(int argc, char **argv)
g_unix_signal_add(SIGTERM, exit_on_signal, NULL);
g_unix_signal_add(SIGHUP, restart_on_signal, NULL);
struct sigaction sa = { .sa_handler = signal_fatal, .sa_flags = 0 };
struct sigaction sa = { .sa_handler = signal_fatal, .sa_flags = SA_RESETHAND };
sigemptyset(&sa.sa_mask);
sigaction(SIGABRT, &sa, 0);
sigaction(SIGBUS, &sa, 0);
sigaction(SIGFPE, &sa, 0);
sigaction(SIGILL, &sa, 0);
sigaction(SIGSEGV, &sa, 0);
/* We have no clue where the input focus is right now */