aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2012-03-05 20:29:00 +0100
committerEelco Dolstra <e.dolstra@tudelft.nl>2012-03-05 20:29:00 +0100
commit35355fc1fcffbe859395e360c0a6a1463f137d63 (patch)
tree0d5ed221e64ca64303c2f88dcf68cc054ba5e8e6 /src/libstore
parent7b22bec252a155514d811a8e2acc21562ac02bd4 (diff)
Set the close-on-exec flag on file descriptors
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc5
-rw-r--r--src/libstore/gc.cc1
-rw-r--r--src/libstore/pathlocks.cc2
3 files changed, 5 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 5bdd49bac..467f16597 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -492,6 +492,7 @@ void UserLock::acquire()
AutoCloseFD fd = open(fnUserLock.c_str(), O_RDWR | O_CREAT, 0600);
if (fd == -1)
throw SysError(format("opening user lock `%1%'") % fnUserLock);
+ closeOnExec(fd);
if (lockFile(fd, ltWrite, false)) {
fdUserLock = fd.borrow();
@@ -1792,9 +1793,6 @@ void DerivationGoal::startBuilder()
if (chdir(tmpDir.c_str()) == -1)
throw SysError(format("changing into `%1%'") % tmpDir);
- /* Close all other file descriptors. */
- closeMostFDs(set<int>());
-
#ifdef CAN_DO_LINUX32_BUILDS
if (drv.platform == "i686-linux" && thisSystem == "x86_64-linux") {
if (personality(0x0008 | 0x8000000 /* == PER_LINUX32_3GB */) == -1)
@@ -2026,6 +2024,7 @@ Path DerivationGoal::openLogFile()
O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (fdLogFile == -1)
throw SysError(format("creating log file `%1%'") % logFileName);
+ closeOnExec(fdLogFile);
return logFileName;
}
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index e1e7b4c1c..e27c63de2 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -40,6 +40,7 @@ int LocalStore::openGCLock(LockType lockType)
AutoCloseFD fdGCLock = open(fnGCLock.c_str(), O_RDWR | O_CREAT, 0600);
if (fdGCLock == -1)
throw SysError(format("opening global GC lock `%1%'") % fnGCLock);
+ closeOnExec(fdGCLock);
if (!lockFile(fdGCLock, lockType, false)) {
printMsg(lvlError, format("waiting for the big garbage collector lock..."));
diff --git a/src/libstore/pathlocks.cc b/src/libstore/pathlocks.cc
index 645f4cd67..b858ed238 100644
--- a/src/libstore/pathlocks.cc
+++ b/src/libstore/pathlocks.cc
@@ -20,6 +20,8 @@ int openLockFile(const Path & path, bool create)
if (fd == -1 && (create || errno != ENOENT))
throw SysError(format("opening lock file `%1%'") % path);
+ closeOnExec(fd);
+
return fd.borrow();
}