Fix failed reload via systemd

fixes #10226
This commit is contained in:
Michael Friedrich 2015-12-16 15:57:59 +01:00 committed by Gunnar Beutner
parent 187a61dfaa
commit 99efc7be2c
1 changed files with 9 additions and 2 deletions

View 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