mirror of https://github.com/Icinga/icinga2.git
parent
73629172b4
commit
8516e78b92
|
@ -530,6 +530,11 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
|
||||||
if (m_Process == 0) {
|
if (m_Process == 0) {
|
||||||
// child process
|
// child process
|
||||||
|
|
||||||
|
if (setsid() < 0) {
|
||||||
|
perror("setsid() failed");
|
||||||
|
_exit(128);
|
||||||
|
}
|
||||||
|
|
||||||
if (dup2(fds[1], STDOUT_FILENO) < 0 || dup2(fds[1], STDERR_FILENO) < 0) {
|
if (dup2(fds[1], STDOUT_FILENO) < 0 || dup2(fds[1], STDERR_FILENO) < 0) {
|
||||||
perror("dup2() failed");
|
perror("dup2() failed");
|
||||||
_exit(128);
|
_exit(128);
|
||||||
|
@ -611,14 +616,14 @@ bool Process::DoEvents(void)
|
||||||
|
|
||||||
if (timeout < Utility::GetTime()) {
|
if (timeout < Utility::GetTime()) {
|
||||||
Log(LogWarning, "Process")
|
Log(LogWarning, "Process")
|
||||||
<< "Killing process " << m_PID << " (" << PrettyPrintArguments(m_Arguments)
|
<< "Killing process group " << m_PID << " (" << PrettyPrintArguments(m_Arguments)
|
||||||
<< ") after timeout of " << m_Timeout << " seconds";
|
<< ") after timeout of " << m_Timeout << " seconds";
|
||||||
|
|
||||||
m_OutputStream << "<Timeout exceeded.>";
|
m_OutputStream << "<Timeout exceeded.>";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
TerminateProcess(m_Process, 1);
|
TerminateProcess(m_Process, 1);
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
kill(m_Process, SIGKILL);
|
kill(-m_Process, SIGKILL);
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
is_timeout = true;
|
is_timeout = true;
|
||||||
|
|
Loading…
Reference in New Issue