From 8516e78b92a65204f2e83c972c8395524419c786 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 11 Mar 2015 07:12:59 +0100 Subject: [PATCH] Kill entire process group after plugin timeout fixes #8540 --- lib/base/process.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/base/process.cpp b/lib/base/process.cpp index b8eb93b86..5f66940a7 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -530,6 +530,11 @@ void Process::Run(const boost::function& callback) if (m_Process == 0) { // child process + if (setsid() < 0) { + perror("setsid() failed"); + _exit(128); + } + if (dup2(fds[1], STDOUT_FILENO) < 0 || dup2(fds[1], STDERR_FILENO) < 0) { perror("dup2() failed"); _exit(128); @@ -611,14 +616,14 @@ bool Process::DoEvents(void) if (timeout < Utility::GetTime()) { Log(LogWarning, "Process") - << "Killing process " << m_PID << " (" << PrettyPrintArguments(m_Arguments) + << "Killing process group " << m_PID << " (" << PrettyPrintArguments(m_Arguments) << ") after timeout of " << m_Timeout << " seconds"; m_OutputStream << ""; #ifdef _WIN32 TerminateProcess(m_Process, 1); #else /* _WIN32 */ - kill(m_Process, SIGKILL); + kill(-m_Process, SIGKILL); #endif /* _WIN32 */ is_timeout = true; -- 2.40.0