diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 08:15:03 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2016-03-24 08:15:03 +0100 |
commit | 6c153dc8de71f204cd03deaf4fb1bdbe2d3aa6a9 (patch) | |
tree | 553dc759fef1fdb0f00da35d857f38cd5294ef6a /fbi.c | |
parent | 8af2652bcc7b343a6fec7d48b4a441905d76ba2c (diff) | |
download | fbida-6c153dc8de71f204cd03deaf4fb1bdbe2d3aa6a9.tar.gz |
move signal handling out of fb code
Diffstat (limited to 'fbi.c')
-rw-r--r-- | fbi.c | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -1408,6 +1408,41 @@ static void cleanup_and_exit(int code) exit(code); } +static jmp_buf fb_fatal_cleanup; + +static void catch_exit_signal(int signal) +{ + siglongjmp(fb_fatal_cleanup,signal); +} + +static void exit_signals_init(void) +{ + struct sigaction act,old; + int termsig; + + memset(&act,0,sizeof(act)); + act.sa_handler = catch_exit_signal; + sigemptyset(&act.sa_mask); + sigaction(SIGINT, &act,&old); + sigaction(SIGQUIT,&act,&old); + sigaction(SIGTERM,&act,&old); + + sigaction(SIGABRT,&act,&old); + sigaction(SIGTSTP,&act,&old); + + sigaction(SIGBUS, &act,&old); + sigaction(SIGILL, &act,&old); + sigaction(SIGSEGV,&act,&old); + + if (0 == (termsig = sigsetjmp(fb_fatal_cleanup,0))) + return; + + /* cleanup */ + gfx->cleanup_display(); + fprintf(stderr,"Oops: %s\n",strsignal(termsig)); + exit(42); +} + int main(int argc, char *argv[]) { @@ -1494,7 +1529,7 @@ main(int argc, char *argv[]) gfx = fb_init(cfg_get_str(O_DEVICE), cfg_get_str(O_VIDEO_MODE), GET_VT()); - fb_catch_exit_signals(); + exit_signals_init(); fb_switch_init(); shadow_init(gfx); signal(SIGTSTP,SIG_IGN); |