Add Process::GetPID and make it work on Unix and Windows.

Refs #6118
This commit is contained in:
Gerd von Egidy 2014-05-18 18:04:34 +02:00 committed by Gunnar Beutner
parent e0d4b9fb80
commit 541de0de78
3 changed files with 11 additions and 7 deletions

View File

@ -314,8 +314,8 @@ pid_t Application::StartReloadProcess(void)
Process::Ptr process = make_shared<Process>(Process::PrepareCommand(args));
process->SetTimeout(300);
process->Run(&ReloadProcessCallback);
return process->GetHandle();
return process->GetPID();
}
/**

View File

@ -410,9 +410,10 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
m_Process = pi.hProcess;
m_FD = outReadPipe;
m_PID = pi.dwProcessId;
Log(LogInformation, "base", "Running command '" + m_Arguments +
"': PID " + Convert::ToString(pi.dwProcessId));
"': PID " + Convert::ToString(m_PID));
#else /* _WIN32 */
int fds[2];
@ -514,8 +515,10 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
// parent process
m_PID = m_Process;
Log(LogInformation, "base", "Running command '" + boost::algorithm::join(m_Arguments, " ") +
"': PID " + Convert::ToString(m_Process));
"': PID " + Convert::ToString(m_PID));
m_Arguments.clear();
@ -636,9 +639,9 @@ bool Process::DoEvents(void)
return false;
}
Process::ProcessHandle Process::GetHandle(void) const
pid_t Process::GetPID(void) const
{
return m_Process;
return m_PID;
}

View File

@ -73,7 +73,7 @@ public:
void Run(const boost::function<void (const ProcessResult&)>& callback = boost::function<void (const ProcessResult&)>());
ProcessHandle GetHandle(void) const;
pid_t GetPID(void) const;
static Arguments PrepareCommand(const Value& command);
@ -87,6 +87,7 @@ private:
double m_Timeout;
ProcessHandle m_Process;
pid_t m_PID;
ConsoleHandle m_FD;
std::ostringstream m_OutputStream;