mirror of https://github.com/Icinga/icinga2.git
parent
7930ae5094
commit
3e8f78e2cc
|
@ -138,11 +138,10 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
|
|
||||||
if (pid < 0) {
|
int errorCode = 0;
|
||||||
BOOST_THROW_EXCEPTION(posix_error()
|
|
||||||
<< boost::errinfo_api_function("fork")
|
if (pid < 0)
|
||||||
<< boost::errinfo_errno(errno));
|
errorCode = errno;
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// child process
|
// child process
|
||||||
|
@ -203,6 +202,8 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
|
||||||
|
|
||||||
Dictionary::Ptr response = new Dictionary();
|
Dictionary::Ptr response = new Dictionary();
|
||||||
response->Set("rc", pid);
|
response->Set("rc", pid);
|
||||||
|
if (errorCode)
|
||||||
|
response->Set("errno", errorCode);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,6 +425,10 @@ send_message:
|
||||||
String jresponse = String(buf, buf + rc);
|
String jresponse = String(buf, buf + rc);
|
||||||
|
|
||||||
Dictionary::Ptr response = JsonDecode(jresponse);
|
Dictionary::Ptr response = JsonDecode(jresponse);
|
||||||
|
|
||||||
|
if (response->Get("rc") == -1)
|
||||||
|
errno = response->Get("errno");
|
||||||
|
|
||||||
return response->Get("rc");
|
return response->Get("rc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,6 +983,11 @@ void Process::Run(const boost::function<void(const ProcessResult&)>& callback)
|
||||||
m_Process = ProcessSpawn(m_Arguments, m_ExtraEnvironment, m_AdjustPriority, fds);
|
m_Process = ProcessSpawn(m_Arguments, m_ExtraEnvironment, m_AdjustPriority, fds);
|
||||||
m_PID = m_Process;
|
m_PID = m_Process;
|
||||||
|
|
||||||
|
if (m_PID == -1) {
|
||||||
|
m_OutputStream << "Fork failed with error code " << errno << " (" << Utility::FormatErrorNumber(errno) << ")";
|
||||||
|
Log(LogCritical, "Process", m_OutputStream.str());
|
||||||
|
}
|
||||||
|
|
||||||
Log(LogNotice, "Process")
|
Log(LogNotice, "Process")
|
||||||
<< "Running command " << PrettyPrintArguments(m_Arguments) << ": PID " << m_PID;
|
<< "Running command " << PrettyPrintArguments(m_Arguments) << ": PID " << m_PID;
|
||||||
|
|
||||||
|
@ -1079,7 +1089,7 @@ bool Process::DoEvents(void)
|
||||||
<< "PID " << m_PID << " (" << PrettyPrintArguments(m_Arguments) << ") terminated with exit code " << exitcode;
|
<< "PID " << m_PID << " (" << PrettyPrintArguments(m_Arguments) << ") terminated with exit code " << exitcode;
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
int status, exitcode;
|
int status, exitcode;
|
||||||
if (could_not_kill) {
|
if (could_not_kill || m_PID == -1) {
|
||||||
exitcode = 128;
|
exitcode = 128;
|
||||||
} else if (ProcessWaitPID(m_Process, &status) != m_Process) {
|
} else if (ProcessWaitPID(m_Process, &status) != m_Process) {
|
||||||
exitcode = 128;
|
exitcode = 128;
|
||||||
|
|
Loading…
Reference in New Issue