summaryrefslogtreecommitdiff
path: root/src/signals.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/signals.c')
-rw-r--r--src/signals.c34
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);