about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-19T16·09+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-11-19T16·09+0100
commita3e5c99d66e111455c6ddc40759005718016c8dd (patch)
treecabfba77716ba25e6025105758ba86acce5dae3f /src/libutil
parent1256ab3b446d8e35225c36e71abb50ee964ea050 (diff)
nix-daemon: Call exit(), not _exit()
This was preventing destructors from running. In particular, it was
preventing the deletion of the temproot file for each worker
process. It may also have been responsible for the excessive WAL
growth on Hydra (due to the SQLite database not being closed
properly).

Apparently broken by accident in
8e9140cfdef9dbd1eb61e4c75c91d452ab5e4a74.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc7
-rw-r--r--src/libutil/util.hh2
2 files changed, 6 insertions, 3 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