about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 395d9c8b4cd6..23fcf28916be 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -13,6 +13,7 @@ extern "C" {
 }
 
 #include "globals.hh"
+#include "gc.hh"
 #include "shared.hh"
 
 #include "config.h"
@@ -55,6 +56,15 @@ void checkStoreNotSymlink(Path path)
 }
 
 
+struct RemoveTempRoots 
+{
+    ~RemoveTempRoots()
+    {
+        removeTempRoots();
+    }
+};
+
+
 void initDerivationsHelpers();
 
 
@@ -171,6 +181,10 @@ static void initAndRun(int argc, char * * argv)
         else remaining.push_back(arg);
     }
 
+    /* Automatically clean up the temporary roots file when we
+       exit. */
+    RemoveTempRoots removeTempRoots;
+
     run(remaining);
 }