]> granicus.if.org Git - icinga2/commitdiff
Fix failed reload via systemd
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 16 Dec 2015 14:57:59 +0000 (15:57 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 16 Dec 2015 14:57:59 +0000 (15:57 +0100)
fixes #10226

lib/cli/daemoncommand.cpp

index 4618bbd6ba19c209427af4eb61f1758611f64d16..8319d7e3424d2f9e7bf2219fba19dba0fb1ad7d2 100644 (file)
@@ -35,6 +35,7 @@
 #include <boost/tuple/tuple.hpp>
 #include <boost/foreach.hpp>
 #include <iostream>
+#include <fstream>
 
 using namespace icinga;
 namespace po = boost::program_options;
@@ -152,9 +153,15 @@ static void TerminateAndWaitForEnd(pid_t target)
                ret = kill(target, 0);
        }
 
-       // timeout and the process still seems to live: kill it
-       if (ret == 0 || errno != ESRCH)
+       // timeout and the process still seems to live: update pid and kill it
+       if (ret == 0 || errno != ESRCH) {
+               String pidFile = Application::GetPidPath();
+               std::ofstream fp(pidFile.CStr());
+               fp << Utility::GetPid();
+               fp.close();
+
                kill(target, SIGKILL);
+       }
 
 #else
        // TODO: implement this for Win32