Use PR_SET_PDEATHSIG to ensure child cleanup

This commit is contained in:
Eelco Dolstra 2014-08-21 15:31:43 +02:00 committed by Ludovic Courtès
parent 909f1260e2
commit 1f8456ff13
1 changed files with 8 additions and 0 deletions

View File

@ -19,6 +19,10 @@
#include <sys/syscall.h>
#endif
#ifdef __linux__
#include <sys/prctl.h>
#endif
extern char * * environ;
@ -867,6 +871,10 @@ pid_t startProcess(std::function<void()> fun,
if (pid == 0) {
_writeToStderr = 0;
try {
#if __linux__
if (dieWithParent && prctl(PR_SET_PDEATHSIG, SIGKILL) == -1)
throw SysError("setting death signal");
#endif
restoreAffinity();
fun();
} catch (std::exception & e) {