From 1f8456ff13dadb96c8540df240505a2d01a22f6c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Aug 2014 15:31:43 +0200 Subject: [PATCH] Use PR_SET_PDEATHSIG to ensure child cleanup --- nix/libutil/util.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index a4a1ddb12a..9bb6ba3ea0 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc @@ -19,6 +19,10 @@ #include #endif +#ifdef __linux__ +#include +#endif + extern char * * environ; @@ -867,6 +871,10 @@ pid_t startProcess(std::function 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) {