From 60bceccafe3d9a570d699428e16a480597cf9d66 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 5 Jun 2009 23:44:37 +0200 Subject: [PATCH] Fix the SIGSEGV handling We can't use libev's signal handling here but have to use sigaction() directly, because libev only writes to a pipe in the real signal handler and then calls our callback in the next main loop iteration. The problem here is that returning from a SIGSEGV signal handler is a in general a Bad Idea (tm) and thus we need to use a "direct" signal handler. Signed-off-by: Uli Schlachter Signed-off-by: Julien Danjou --- awesome.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/awesome.c b/awesome.c index fd8ecd70f..ec748d368 100644 --- a/awesome.c +++ b/awesome.c @@ -236,7 +236,7 @@ xerrorstart(void * data __attribute__ ((unused)), } static void -signal_fatal(EV_P_ ev_signal *w, int revents) +signal_fatal(int signum) { buffer_t buf; backtrace_get(&buf); @@ -408,7 +408,6 @@ main(int argc, char **argv) ev_signal_init(&sigint, exit_on_signal, SIGINT); ev_signal_init(&sigterm, exit_on_signal, SIGTERM); ev_signal_init(&sighup, restart_on_signal, SIGHUP); - ev_signal_init(&sighup, signal_fatal, SIGSEGV); ev_signal_start(globalconf.loop, &sigint); ev_signal_start(globalconf.loop, &sigterm); ev_signal_start(globalconf.loop, &sighup); @@ -416,6 +415,10 @@ main(int argc, char **argv) ev_unref(globalconf.loop); ev_unref(globalconf.loop); + struct sigaction sa = { .sa_handler = signal_fatal, .sa_flags = 0 }; + sigemptyset(&sa.sa_mask); + sigaction(SIGSEGV, &sa, 0); + /* X stuff */ globalconf.connection = xcb_connect(NULL, &globalconf.default_screen); if(xcb_connection_has_error(globalconf.connection))