about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-06-27T13·52-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-06-27T13·52-0400
commit42f5a2fc297f841d982f07062c653b27557a3cd5 (patch)
treedf9c26478af7db3fb567f836b70a836ce6bafc29 /src
parent3ee208516fbdd302b178d68a20dd44517a276a96 (diff)
Mount an empty /dev/shm tmpfs in the chroot
This ensures that whatever the builder writes in /dev/shm is
automatically cleaned up.
Diffstat (limited to 'src')
-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 e7a8ee434a..246e0d9da8 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