diff options
author | Dennis Real <github@tildepipe.org> | 2012-03-16 19:13:47 +0100 |
---|---|---|
committer | Dennis Real <github@tildepipe.org> | 2012-03-16 19:13:47 +0100 |
commit | 8e96382805eb77a82209df9d71dbf9c0dd1c4cdb (patch) | |
tree | 48c54b9715d88cb6e9f8455d689364b73b842f8f /src/signals.c | |
parent | 77fa5aca182435f2771511832ea198d027393ceb (diff) | |
parent | 29cd868898660c58b1925bf3647c4c63b7bd3151 (diff) |
Merge branch 'master' of git://github.com/derf/feh
Diffstat (limited to 'src/signals.c')
-rw-r--r-- | src/signals.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/signals.c b/src/signals.c index d5a6899..0b18aac 100644 --- a/src/signals.c +++ b/src/signals.c @@ -36,9 +36,13 @@ void setup_signal_handlers() if ( (sigemptyset(&feh_ss) == -1) || (sigaddset(&feh_ss, SIGUSR1) == -1) || - (sigaddset(&feh_ss, SIGUSR2) == -1)) + (sigaddset(&feh_ss, SIGUSR2) == -1) || + (sigaddset(&feh_ss, SIGALRM) == -1) || + (sigaddset(&feh_ss, SIGTERM) == -1) || + (sigaddset(&feh_ss, SIGQUIT) == -1) || + (sigaddset(&feh_ss, SIGINT) == -1)) { - weprintf("Failed to set up signal mask, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal masks"); return; } @@ -48,9 +52,13 @@ void setup_signal_handlers() if ( (sigaction(SIGUSR1, &feh_sh, NULL) == -1) || - (sigaction(SIGUSR2, &feh_sh, NULL) == -1)) + (sigaction(SIGUSR2, &feh_sh, NULL) == -1) || + (sigaction(SIGALRM, &feh_sh, NULL) == -1) || + (sigaction(SIGTERM, &feh_sh, NULL) == -1) || + (sigaction(SIGQUIT, &feh_sh, NULL) == -1) || + (sigaction(SIGINT, &feh_sh, NULL) == -1)) { - weprintf("Failed to set up signal handler, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal handler"); return; } @@ -59,10 +67,24 @@ void setup_signal_handlers() void feh_handle_signal(int signo) { - winwidget winwid - = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + winwidget winwid; int i; + switch (signo) { + case SIGALRM: + if (childpid) + killpg(childpid, SIGINT); + return; + case SIGINT: + case SIGTERM: + case SIGQUIT: + if (childpid) + killpg(childpid, SIGINT); + exit(128 + signo); + } + + winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + if (winwid) { if (signo == SIGUSR1) slideshow_change_image(winwid, SLIDE_NEXT, 1); |