From 4e7717cf14b29bc39ba8139e02f34b3510c49deb Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sun, 28 Dec 2014 01:21:10 -0500 Subject: redshift: Properly handle errors in sigaction --- src/redshift.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/redshift.c b/src/redshift.c index 4a5bfbf..8950097 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -1404,14 +1404,29 @@ main(int argc, char *argv[]) sigact.sa_handler = sigexit; sigact.sa_mask = sigset; sigact.sa_flags = 0; - sigaction(SIGINT, &sigact, NULL); - sigaction(SIGTERM, &sigact, NULL); - /* Install signal handler for USR1 singal */ + r = sigaction(SIGINT, &sigact, NULL); + if (r < 0) { + perror("sigaction"); + exit(EXIT_FAILURE); + } + + r = sigaction(SIGTERM, &sigact, NULL); + if (r < 0) { + perror("sigaction"); + exit(EXIT_FAILURE); + } + + /* Install signal handler for USR1 signal */ sigact.sa_handler = sigdisable; sigact.sa_mask = sigset; sigact.sa_flags = 0; - sigaction(SIGUSR1, &sigact, NULL); + + r = sigaction(SIGUSR1, &sigact, NULL); + if (r < 0) { + perror("sigaction"); + exit(EXIT_FAILURE); + } #endif /* HAVE_SIGNAL_H && ! __WIN32__ */ if (verbose) { -- cgit v1.2.3-70-g09d2