From 202567dc12618dd1b7900c6d8c4c829dc4ece130 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 7 Mar 2014 10:51:39 +0100 Subject: [PATCH] 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 --- awesome.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awesome.c b/awesome.c index 3cef91e1..e4945d94 100644 --- a/awesome.c +++ b/awesome.c @@ -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 */