diff options
author | Daniel Friesel <derf@finalrewind.org> | 2012-03-13 00:45:13 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2012-03-13 00:45:13 +0100 |
commit | 8f5bf736a9d3f8084c644dbf6ceefc4142715c4e (patch) | |
tree | cc912d82821c91b48f248a0dc6fe69d31e400861 /src/signals.c | |
parent | cbab594f051b5c21a76d0ad389a25d6449e0b839 (diff) |
Experimental code to limit imagemagick convert runtime (see #82)
Problems so far:
* leaks zombie processes
* does not work when terminating feh with a signal (since the convert process
is no longer in feh's process group)
Diffstat (limited to 'src/signals.c')
-rw-r--r-- | src/signals.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/signals.c b/src/signals.c index d5a6899..91f6bf3 100644 --- a/src/signals.c +++ b/src/signals.c @@ -36,9 +36,10 @@ 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)) { - weprintf("Failed to set up signal mask, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal masks"); return; } @@ -48,9 +49,10 @@ 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)) { - weprintf("Failed to set up signal handler, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal handler"); return; } @@ -59,10 +61,16 @@ 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; + if (signo == SIGALRM) { + killpg(childpid, SIGINT); + kill(childpid, SIGINT); + return; + } + winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + if (winwid) { if (signo == SIGUSR1) slideshow_change_image(winwid, SLIDE_NEXT, 1); |