mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-20 12:14:44 +02:00
Implemented SIGINT handler
This commit is contained in:
parent
6fea4d6baa
commit
2e8ed6a6b5
@ -359,3 +359,15 @@ bool Application::IsDebugging(void) const
|
||||
{
|
||||
return m_Debugging;
|
||||
}
|
||||
|
||||
void Application::SigIntHandler(int signum)
|
||||
{
|
||||
Application::Instance->Shutdown();
|
||||
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
@ -45,8 +45,14 @@ public:
|
||||
const string& GetExeDirectory(void);
|
||||
|
||||
bool IsDebugging(void) const;
|
||||
void SigIntHandler(int signum);
|
||||
};
|
||||
|
||||
inline void sigint_handler(int signum)
|
||||
{
|
||||
Application::Instance->SigIntHandler(signum);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
int application_main(int argc, char **argv)
|
||||
{
|
||||
@ -54,6 +60,13 @@ int application_main(int argc, char **argv)
|
||||
|
||||
Application::Instance = make_shared<T>();
|
||||
|
||||
#ifndef _WIN32
|
||||
struct sigaction sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sa_handler = sigint_handler;
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
vector<string> args;
|
||||
|
||||
for (int i = 0; i < argc; i++)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
void Sleep(unsigned long milliseconds);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user