]> 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)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 23 Feb 2016 08:16:01 +0000 (09:16 +0100)
fixes #10226

lib/cli/daemoncommand.cpp

index 7f225820fb66b3b9ec7cc511a69be44bdf6ac377..f650af3a4c91cb0dcb23e654cfa5cdcde3974265 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