]> granicus.if.org Git - icinga2/commitdiff
Implement signal handler for SIGTERM.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 17 Nov 2013 18:58:32 +0000 (19:58 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 17 Nov 2013 19:04:27 +0000 (20:04 +0100)
Fixes #5087

lib/base/application.cpp
lib/base/application.h

index 8315a6b6031dd3b1d25165d0fd80a1d83032ff85..690240e3d54585d3c319513a6079732f32b5a22a 100644 (file)
@@ -327,17 +327,17 @@ void Application::DisplayBugMessage(void)
 
 #ifndef _WIN32
 /**
- * Signal handler for SIGINT. Prepares the application for cleanly
+ * Signal handler for SIGINT and SIGTERM. Prepares the application for cleanly
  * shutting down during the next execution of the event loop.
  *
  * @param - The signal number.
  */
-void Application::SigIntHandler(int)
+void Application::SigIntTermHandler(int signum)
 {
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
        sa.sa_handler = SIG_DFL;
-       sigaction(SIGINT, &sa, NULL);
+       sigaction(signum, &sa, NULL);
 
        Application::Ptr instance = Application::GetInstance();
 
@@ -466,8 +466,9 @@ int Application::Run(void)
 #ifndef _WIN32
        struct sigaction sa;
        memset(&sa, 0, sizeof(sa));
-       sa.sa_handler = &Application::SigIntHandler;
+       sa.sa_handler = &Application::SigIntTermHandler;
        sigaction(SIGINT, &sa, NULL);
+       sigaction(SIGTERM, &sa, NULL);
 
        sa.sa_handler = SIG_IGN;
        sigaction(SIGPIPE, &sa, NULL);
index 19b64fb58824f4a7ef65ab4e8f7d27ee98ea4ee7..0904ad28afe453854219b6f0a7787ad98ed0f9a9 100644 (file)
@@ -116,7 +116,7 @@ private:
        static double m_StartTime;
 
 #ifndef _WIN32
-       static void SigIntHandler(int signum);
+       static void SigIntTermHandler(int signum);
 #else /* _WIN32 */
        static BOOL WINAPI CtrlHandler(DWORD type);
        static LONG WINAPI SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi);