]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
main: move signal handler setting to util.c
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 27 Jul 2015 12:27:41 +0000 (14:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 28 Jul 2015 09:57:57 +0000 (11:57 +0200)
main.c
util.c
util.h

diff --git a/main.c b/main.c
index 393b12e4b9eab0522391da49ae15810758109a09..c3c55744c96e494de149fb312465c2a1cd1e517b 100644 (file)
--- a/main.c
+++ b/main.c
@@ -51,6 +51,7 @@
 #include "nameserv.h"
 #include "smooth.h"
 #include "tempcomp.h"
+#include "util.h"
 
 /* ================================================== */
 
@@ -522,12 +523,7 @@ int main
     post_init_rtc_hook(NULL);
   }
 
-  signal(SIGINT, signal_cleanup);
-  signal(SIGTERM, signal_cleanup);
-#if !defined(WINNT)
-  signal(SIGQUIT, signal_cleanup);
-  signal(SIGHUP, signal_cleanup);
-#endif /* WINNT */
+  UTI_SetQuitSignalsHandler(signal_cleanup);
 
   /* The program normally runs under control of the main loop in
      the scheduler. */
diff --git a/util.c b/util.c
index 2f2c462752c5ec2c30c146e5dd19110027553f5d..126c74f9d83665323e525b06e3f77837bf91b3c7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -839,3 +839,17 @@ UTI_DecodePasswordFromText(char *key)
     return len;
   }
 }
+
+/* ================================================== */
+
+int
+UTI_SetQuitSignalsHandler(void (*handler)(int))
+{
+  signal(SIGINT, handler);
+  signal(SIGTERM, handler);
+#if !defined(WINNT)
+  signal(SIGQUIT, handler);
+  signal(SIGHUP, handler);
+#endif /* WINNT */
+  return 1;
+}
diff --git a/util.h b/util.h
index cb084ed7acd57099c643588bb3e8c9b0310ca548..68afb78bf16cfbe3e2d735c2f6c09839bf390eeb 100644 (file)
--- a/util.h
+++ b/util.h
@@ -127,4 +127,6 @@ extern int UTI_CheckNTPAuth(int hash_id, const unsigned char *key, int key_len,
 /* Decode password encoded in ASCII or HEX */
 extern int UTI_DecodePasswordFromText(char *key);
 
+extern int UTI_SetQuitSignalsHandler(void (*handler)(int));
+
 #endif /* GOT_UTIL_H */