#endif /* _WIN32 */
}
-#ifndef _WIN32
-/**
- * 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::SigIntTermHandler(int signum)
-{
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
- sa.sa_handler = SIG_DFL;
- sigaction(signum, &sa, nullptr);
-
- Application::Ptr instance = Application::GetInstance();
-
- if (!instance)
- return;
-
- instance->RequestShutdown();
-}
-#endif /* _WIN32 */
-
/**
* Signal handler for SIGUSR1. This signal causes Icinga to re-open
* its log files and is mainly for use by logrotate.
RequestReopenLogs();
}
-/**
- * Signal handler for SIGUSR2. Hands over PID to child and commits suicide
- *
- * @param - The signal number.
- */
-void Application::SigUsr2Handler(int)
-{
- Log(LogInformation, "Application", "Reload requested, letting new process take over.");
-#ifdef HAVE_SYSTEMD
- sd_notifyf(0, "MAINPID=%lu", (unsigned long) m_ReloadProcess);
-#endif /* HAVE_SYSTEMD */
-
- /* Write the PID of the new process to the pidfile before this
- * process exits to keep systemd happy.
- */
- Application::Ptr instance = GetInstance();
- try {
- instance->UpdatePidFile(Configuration::PidPath, m_ReloadProcess);
- } catch (const std::exception&) {
- /* abort restart */
- Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
- return;
- }
-
- instance->ClosePidFile(false);
-
- /* Ensure to dump the program state on reload. */
- ConfigObject::StopObjects();
- instance->OnShutdown();
-
- Log(LogInformation, "Application")
- << "Reload done, parent process shutting down. Child process with PID '" << m_ReloadProcess << "' is taking over.";
-
- Exit(0);
-}
-
/**
* Signal handler for SIGABRT. Helps with debugging ASSERT()s.
*
#ifndef _WIN32
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
- sa.sa_handler = &Application::SigIntTermHandler;
- sigaction(SIGINT, &sa, nullptr);
- sigaction(SIGTERM, &sa, nullptr);
-
sa.sa_handler = &Application::SigUsr1Handler;
sigaction(SIGUSR1, &sa, nullptr);
-
- sa.sa_handler = &Application::SigUsr2Handler;
- sigaction(SIGUSR2, &sa, nullptr);
#else /* _WIN32 */
SetConsoleCtrlHandler(&Application::CtrlHandler, TRUE);
#endif /* _WIN32 */
static bool m_ScriptDebuggerEnabled;
static double m_LastReloadFailed;
-#ifndef _WIN32
- static void SigIntTermHandler(int signum);
-#else /* _WIN32 */
+#ifdef _WIN32
static BOOL WINAPI CtrlHandler(DWORD type);
static LONG WINAPI SEHUnhandledExceptionFilter(PEXCEPTION_POINTERS exi);
#endif /* _WIN32 */
static void SigAbrtHandler(int signum);
static void SigUsr1Handler(int signum);
- static void SigUsr2Handler(int signum);
static void ExceptionHandler();
static String GetCrashReportFilename();
REGISTER_CLICOMMAND("daemon", DaemonCommand);
-#ifndef _WIN32
-static void SigHupHandler(int)
-{
- Application::RequestRestart();
-}
-#endif /* _WIN32 */
-
/*
* Daemonize(). On error, this function logs by itself and exits (i.e. does not return).
*
<< "Cannot clean ignored downtimes/comments: " << ex.what();
}
-#ifndef _WIN32
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
- sa.sa_handler = &SigHupHandler;
- sigaction(SIGHUP, &sa, nullptr);
-#endif /* _WIN32 */
-
ApiListener::UpdateObjectAuthority();
return Application::GetInstance()->Run();