From 778b51ab6d9fd2d68133c2996780e6cdb63cf896 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 23 May 2014 19:00:55 +0200 Subject: [PATCH] Improve log messages for the Process class. Refs #6070 --- lib/base/process.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 0b286c4fc..230dce5f3 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -531,7 +531,7 @@ void Process::Run(const boost::function& callback) m_PID = m_Process; - Log(LogNotice, "base", "Running command '" + boost::algorithm::join(m_Arguments, " ") + + Log(LogNotice, "base", "Running command '" + boost::algorithm::join(m_Arguments, "', '") + "': PID " + Convert::ToString(m_PID)); m_Arguments.clear(); @@ -582,6 +582,8 @@ bool Process::DoEvents(void) double timeout = m_Result.ExecutionStart + m_Timeout; if (timeout < Utility::GetTime()) { + Log(LogNotice, "base", "Killing process '" + Convert::ToString(m_PID) + " after timeout of " + Convert::ToString(m_Timeout) + " seconds"); + m_OutputStream << ""; #ifdef _WIN32 TerminateProcess(m_Process, 1); @@ -627,6 +629,8 @@ bool Process::DoEvents(void) DWORD exitcode; GetExitCodeProcess(m_Process, &exitcode); + + Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode)); #else /* _WIN32 */ int status, exitcode; if (waitpid(m_Process, &status, 0) != m_Process) { @@ -637,14 +641,16 @@ bool Process::DoEvents(void) if (WIFEXITED(status)) { exitcode = WEXITSTATUS(status); - } - else if (WIFSIGNALED(status)) { + + Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " terminated with exit code " + Convert::ToString(exitcode)); + } else if (WIFSIGNALED(status)) { + Log(LogNotice, "base", "PID " + Convert::ToString(m_PID) + " was terminated by signal " + Convert::ToString(WTERMSIG(status))); + std::ostringstream outputbuf; outputbuf << ""; output = output + outputbuf.str(); exitcode = 128; - } - else { + } else { exitcode = 128; } #endif /* _WIN32 */