]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Log when exiting due to a SIGTERM signal 11669/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 1 Jun 2022 15:14:14 +0000 (17:14 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 1 Jun 2022 15:14:14 +0000 (17:14 +0200)
The recursor already does the same, and it might be useful to understand
why the process was terminated.

pdns/dnsdist.cc

index a4805d03e4cd58304464f76454015da00d814f36..1afb17f012503a276b04ad1ba50f92f684e1a0d6 100644 (file)
@@ -2191,12 +2191,22 @@ static void cleanupLuaObjects()
   clearWebHandlers();
 }
 
-static void sighandler(int sig)
+static void sigTermHandler(int)
 {
   cleanupLuaObjects();
   exit(EXIT_SUCCESS);
 }
-#endif
+#else /* COVERAGE */
+static void sigTermHandler(int)
+{
+  if (g_syslog) {
+    syslog(LOG_INFO, "Exiting on user request");
+  }
+  std::cout<<"Exiting on user request"<<std::endl;
+
+  _exit(EXIT_SUCCESS);
+}
+#endif /* COVERAGE */
 
 int main(int argc, char** argv)
 {
@@ -2212,9 +2222,7 @@ int main(int argc, char** argv)
 
     signal(SIGPIPE, SIG_IGN);
     signal(SIGCHLD, SIG_IGN);
-#ifdef COVERAGE
-    signal(SIGTERM, sighandler);
-#endif
+    signal(SIGTERM, sigTermHandler);
 
     openlog("dnsdist", LOG_PID|LOG_NDELAY, LOG_DAEMON);