MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ProcessWaitPID

Function ProcessWaitPID

lib/base/process.cpp:475–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473}
474
475static int ProcessWaitPID(pid_t pid, int *status)
476{
477 Dictionary::Ptr request = new Dictionary({
478 { "command", "waitpid" },
479 { "pid", pid }
480 });
481
482 String jrequest = JsonEncode(request);
483 size_t length = jrequest.GetLength();
484
485 std::unique_lock<std::mutex> lock(l_ProcessControlMutex);
486
487 do {
488 while (send(l_ProcessControlFD, &length, sizeof(length), 0) < 0) {
489 StartSpawnProcessHelper();
490 }
491 } while (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0);
492
493 char buf[4096];
494
495 ssize_t rc = recv(l_ProcessControlFD, buf, sizeof(buf), 0);
496
497 if (rc <= 0)
498 return -1;
499
500 String jresponse = String(buf, buf + rc);
501
502 Dictionary::Ptr response = JsonDecode(jresponse);
503 *status = response->Get("status");
504 return response->Get("rc");
505}
506
507void Process::InitializeSpawnHelper()
508{

Callers 1

DoEventsMethod · 0.85

Calls 5

StartSpawnProcessHelperFunction · 0.85
CStrMethod · 0.80
StringClass · 0.70
GetLengthMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected