about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index e7a8ee434a50..246e0d9da86b 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1868,6 +1868,12 @@ void DerivationGoal::initChild()
                private PID namespace. */
             if (mount("none", (chrootRootDir + "/proc").c_str(), "proc", 0, 0) == -1)
                 throw SysError("mounting /proc");
+
+            /* Mount a new tmpfs on /dev/shm to ensure that whatever
+               the builder puts in /dev/shm is cleaned up automatically. */
+            if (pathExists("/dev/shm"))
+                if (mount("none", (chrootRootDir + "/dev/shm").c_str(), "tmpfs", 0, 0) == -1)
+                    throw SysError("mounting /dev/shm");
                     
             /* Do the chroot().  Below we do a chdir() to the
                temporary build directory to make sure the current