diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 825748792a9a7d2353b102efdb15dd06589d5942..80e017a4f197f0423e5d86588aa1882270d26b5e 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -19,6 +19,10 @@
 #include <sys/syscall.h>
 #endif
 
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
 
 extern char * * environ;
 
@@ -847,7 +851,8 @@ void killUser(uid_t uid)
 //////////////////////////////////////////////////////////////////////
 
 
-pid_t startProcess(std::function<void()> fun, const string & errorPrefix)
+pid_t startProcess(std::function<void()> fun,
+    bool dieWithParent, const string & errorPrefix)
 {
     pid_t pid = fork();
     if (pid == -1) throw SysError("unable to fork");
@@ -855,6 +860,10 @@ pid_t startProcess(std::function<void()> fun, const string & errorPrefix)
     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) {
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index f6f5d1b3fee73aefd3faff57444bd2d84e7f2362..4f9f7422c09fbedddcab639d62689561e8ca92de 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -267,7 +267,8 @@ void killUser(uid_t uid);
 
 /* Fork a process that runs the given function, and return the child
    pid to the caller. */
-pid_t startProcess(std::function<void()> fun, const string & errorPrefix = "error: ");
+pid_t startProcess(std::function<void()> fun, bool dieWithParent = true,
+    const string & errorPrefix = "error: ");
 
 
 /* Run a program and return its stdout in a string (i.e., like the
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 6d166c427480d5c05556277c423c46360229bbf9..ced356c34a3d717ffdc208db49c6dd9c19d680dc 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -779,7 +779,7 @@ static void daemonLoop(char * * argv)
                 processConnection(trusted);
 
                 _exit(0);
-            }, "unexpected Nix daemon error: ");
+            }, false, "unexpected Nix daemon error: ");
 
         } catch (Interrupted & e) {
             throw;