From 1676af8b2d8a4296175a774d9e46bd3c63b6217d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 17 Nov 2013 19:58:32 +0100 Subject: [PATCH] Implement signal handler for SIGTERM. Fixes #5087 --- lib/base/application.cpp | 9 +++++---- lib/base/application.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 8315a6b60..690240e3d 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -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); diff --git a/lib/base/application.h b/lib/base/application.h index 19b64fb58..0904ad28a 100644 --- a/lib/base/application.h +++ b/lib/base/application.h @@ -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);