]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
util: handle errors in setting of signal handler as fatal
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 1 Aug 2018 09:59:00 +0000 (11:59 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 3 Aug 2018 15:21:02 +0000 (17:21 +0200)
util.c
util.h

diff --git a/util.c b/util.c
index 72362026f4b86e43d9ed378537422cbf8a95e7e8..811914b7314143bb7c3e9afc606d70d623b3245d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -995,7 +995,7 @@ UTI_FdSetCloexec(int fd)
 
 /* ================================================== */
 
-int
+void
 UTI_SetQuitSignalsHandler(void (*handler)(int))
 {
   struct sigaction sa;
@@ -1003,26 +1003,24 @@ UTI_SetQuitSignalsHandler(void (*handler)(int))
   sa.sa_handler = handler;
   sa.sa_flags = SA_RESTART;
   if (sigemptyset(&sa.sa_mask) < 0)
-    return 0;
+    LOG_FATAL("sigemptyset() failed");
 
 #ifdef SIGINT
   if (sigaction(SIGINT, &sa, NULL) < 0)
-    return 0;
+    LOG_FATAL("sigaction(%d) failed", SIGINT);
 #endif
 #ifdef SIGTERM
   if (sigaction(SIGTERM, &sa, NULL) < 0)
-    return 0;
+    LOG_FATAL("sigaction(%d) failed", SIGTERM);
 #endif
 #ifdef SIGQUIT
   if (sigaction(SIGQUIT, &sa, NULL) < 0)
-    return 0;
+    LOG_FATAL("sigaction(%d) failed", SIGQUIT);
 #endif
 #ifdef SIGHUP
   if (sigaction(SIGHUP, &sa, NULL) < 0)
-    return 0;
+    LOG_FATAL("sigaction(%d) failed", SIGHUP);
 #endif
-
-  return 1;
 }
 
 /* ================================================== */
diff --git a/util.h b/util.h
index 40ff72900a5fe7f3512b6f5c0f5bcddae91e4414..96fdc76a909e1ea58953a30915cfa148b3a9079f 100644 (file)
--- a/util.h
+++ b/util.h
@@ -161,7 +161,7 @@ extern Float UTI_FloatHostToNetwork(double x);
 /* Set FD_CLOEXEC on descriptor */
 extern int UTI_FdSetCloexec(int fd);
 
-extern int UTI_SetQuitSignalsHandler(void (*handler)(int));
+extern void UTI_SetQuitSignalsHandler(void (*handler)(int));
 
 /* Get directory (as an allocated string) for a path */
 extern char *UTI_PathToDir(const char *path);