about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libutil/util.cc7
-rw-r--r--src/libutil/util.hh2
-rw-r--r--src/nix-daemon/nix-daemon.cc4
3 files changed, 8 insertions, 5 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 99d2b1e0adce..305e470ebde0 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -864,7 +864,7 @@ void killUser(uid_t uid)
 
 
 pid_t startProcess(std::function<void()> fun,
-    bool dieWithParent, const string & errorPrefix)
+    bool dieWithParent, const string & errorPrefix, bool runExitHandlers)
 {
     pid_t pid = fork();
     if (pid == -1) throw SysError("unable to fork");
@@ -883,7 +883,10 @@ pid_t startProcess(std::function<void()> fun,
                 std::cerr << errorPrefix << e.what() << "\n";
             } catch (...) { }
         } catch (...) { }
-        _exit(1);
+        if (runExitHandlers)
+            exit(1);
+        else
+            _exit(1);
     }
 
     return pid;
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index b35e02dceb60..628b8a0e1f09 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -270,7 +270,7 @@ 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, bool dieWithParent = true,
-    const string & errorPrefix = "error: ");
+    const string & errorPrefix = "error: ", bool runExitHandlers = false);
 
 
 /* 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 d973e579f37d..3864ab935de0 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -820,8 +820,8 @@ static void daemonLoop(char * * argv)
                 to.fd = remote;
                 processConnection(trusted);
 
-                _exit(0);
-            }, false, "unexpected Nix daemon error: ");
+                exit(0);
+            }, false, "unexpected Nix daemon error: ", true);
 
         } catch (Interrupted & e) {
             throw;