diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-21 15:31:43 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-06-03 17:59:53 +0200 |
commit | 1f8456ff13dadb96c8540df240505a2d01a22f6c (patch) | |
tree | c8e9c72659d0753021b2088fdcbf29f90bc3deb6 | |
parent | 909f1260e269e354c86c833ffb4ca27c9fb135f4 (diff) | |
download | guix-1f8456ff13dadb96c8540df240505a2d01a22f6c.tar.gz |
Use PR_SET_PDEATHSIG to ensure child cleanup
-rw-r--r-- | nix/libutil/util.cc | 8 |
1 files changed, 8 insertions, 0 deletions
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 <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) { |