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

Function StartSpawnProcessHelper

lib/base/process.cpp:343–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343static void StartSpawnProcessHelper()
344{
345 if (l_ProcessControlFD != -1) {
346 (void)close(l_ProcessControlFD);
347
348 int status;
349 (void)waitpid(l_ProcessControlPID, &status, 0);
350 }
351
352 int controlFDs[2];
353 if (socketpair(AF_UNIX, SOCK_STREAM, 0, controlFDs) < 0) {
354 BOOST_THROW_EXCEPTION(posix_error()
355 << boost::errinfo_api_function("socketpair")
356 << boost::errinfo_errno(errno));
357 }
358
359 pid_t pid = fork();
360
361 if (pid < 0) {
362 BOOST_THROW_EXCEPTION(posix_error()
363 << boost::errinfo_api_function("fork")
364 << boost::errinfo_errno(errno));
365 }
366
367 if (pid == 0) {
368 (void)close(controlFDs[1]);
369
370 l_ProcessControlFD = controlFDs[0];
371
372 ProcessHandler();
373
374 _exit(1);
375 }
376
377 (void)close(controlFDs[0]);
378
379 l_ProcessControlFD = controlFDs[1];
380 l_ProcessControlPID = pid;
381}
382
383static pid_t ProcessSpawn(const std::vector<String>& arguments, const Dictionary::Ptr& extraEnvironment, bool adjustPriority, int fds[3])
384{

Callers 4

ProcessSpawnFunction · 0.85
ProcessKillFunction · 0.85
ProcessWaitPIDFunction · 0.85
InitializeSpawnHelperMethod · 0.85

Calls 2

posix_errorClass · 0.85
ProcessHandlerFunction · 0.85

Tested by

no test coverage detected