]> granicus.if.org Git - icinga2/commitdiff
Remove old signal handlers
authorAlexander A. Klimov <alexander.klimov@icinga.com>
Fri, 12 Jul 2019 11:45:54 +0000 (13:45 +0200)
committerAlexander A. Klimov <alexander.klimov@icinga.com>
Mon, 15 Jul 2019 13:06:29 +0000 (15:06 +0200)
refs #5230

lib/base/application.cpp
lib/base/application.hpp
lib/cli/daemoncommand.cpp

index 880af34a24ea0c250def67d40c3097248f3e6ebd..3e140854226d9025c4e0f82b3987998445ec5af3 100644 (file)
@@ -680,29 +680,6 @@ void Application::AttachDebugger(const String& filename, bool interactive)
 #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.
@@ -717,42 +694,6 @@ void Application::SigUsr1Handler(int)
        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.
  *
@@ -999,15 +940,8 @@ int Application::Run()
 #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 */
index 92f627e75c4c2d34c5a55ad17f5098d51d4d618d..ad7fd9606d0d31bcc888fdd0aabb5f5b63e9b1fc 100644 (file)
@@ -132,9 +132,7 @@ private:
        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 */
@@ -143,7 +141,6 @@ private:
 
        static void SigAbrtHandler(int signum);
        static void SigUsr1Handler(int signum);
-       static void SigUsr2Handler(int signum);
        static void ExceptionHandler();
 
        static String GetCrashReportFilename();
index 9fbe486ba96537ebfdbd5fa98691bbf2c10d67dc..38938bf19bed1eed23a7f185c0f2f973e369f5e1 100644 (file)
@@ -27,13 +27,6 @@ static po::variables_map g_AppParams;
 
 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).
  *
@@ -299,13 +292,6 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
                        << "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();