about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T17·52+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-07T17·52+0000
commitc3286ec020dfa20edcad6ad3cea519546e5207f1 (patch)
treea04f82b963e76d88c3053e52c4b68e01ecfa60ab /src/libstore/build.cc
parenta82d80ddeb6f68ff136124dfb591a404bb195ea3 (diff)
* Don't count on the Pid deconstructor to kill the child process,
  since if we're running a build user in non-root mode, we can't.  Let
  the setuid helper do it.

Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 03a708b7477c..184b05c8634f 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -653,12 +653,24 @@ DerivationGoal::DerivationGoal(const Path & drvPath, Worker & worker)
 
 DerivationGoal::~DerivationGoal()
 {
-    if (pid != -1) worker.childTerminated(pid);
-    
     /* Careful: we should never ever throw an exception from a
        destructor. */
     try {
+        if (pid != -1) {
+            worker.childTerminated(pid);
+
+            if (buildUser.enabled()) {
+                /* Can't let pid's destructor do it, since it may not
+                   have the appropriate privilege (i.e., the setuid
+                   helper should do it). */
+                buildUser.kill();
+                pid.wait(true);
+                assert(pid == -1);
+            }
+        }
+        
         deleteTmpDir(false);
+        
     } catch (Error & e) {
         printMsg(lvlError, format("error (ignored): %1%") % e.msg());
     }