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

Function ProcessKill

lib/base/process.cpp:443–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443static int ProcessKill(pid_t pid, int signum)
444{
445 Dictionary::Ptr request = new Dictionary({
446 { "command", "kill" },
447 { "pid", pid },
448 { "signum", signum }
449 });
450
451 String jrequest = JsonEncode(request);
452 size_t length = jrequest.GetLength();
453
454 std::unique_lock<std::mutex> lock(l_ProcessControlMutex);
455
456 do {
457 while (send(l_ProcessControlFD, &length, sizeof(length), 0) < 0) {
458 StartSpawnProcessHelper();
459 }
460 } while (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0);
461
462 char buf[4096];
463
464 ssize_t rc = recv(l_ProcessControlFD, buf, sizeof(buf), 0);
465
466 if (rc <= 0)
467 return -1;
468
469 String jresponse = String(buf, buf + rc);
470
471 Dictionary::Ptr response = JsonDecode(jresponse);
472 return response->Get("errno");
473}
474
475static int ProcessWaitPID(pid_t pid, int *status)
476{

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