aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD.C <pczaplejewicz@pathscale.com>2015-11-13 20:49:02 +0100
committerTim Harder <radhermit@gmail.com>2015-11-22 20:37:19 -0500
commit5dd2da737b70b340c7deb83ac2748ae9450770c9 (patch)
tree9c4103d1cd38f532c06d8852f6a47a63387c9d4b
parentebuild/processor: don't prepend hardcoded system dirs to ebuild env's PATH (diff)
downloadpkgcore-5dd2da737b70b340c7deb83ac2748ae9450770c9.tar.gz
pkgcore-5dd2da737b70b340c7deb83ac2748ae9450770c9.tar.bz2
pkgcore-5dd2da737b70b340c7deb83ac2748ae9450770c9.zip
ebuild/processor: fix FD selection for bash process on OS X
File descriptors were derived from RLIMIT_NOFILE, yielding the value 255, which may be invalid in older bash versions due to a bug in bash. This solution skips the highest two FDs just to be safe. Fixes #147.
-rw-r--r--pkgcore/ebuild/processor.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/pkgcore/ebuild/processor.py b/pkgcore/ebuild/processor.py
index e3865ec9d..1e61e9f2e 100644
--- a/pkgcore/ebuild/processor.py
+++ b/pkgcore/ebuild/processor.py
@@ -347,17 +347,18 @@ class EbuildProcessor(object):
# force to a neutral dir so that sandbox/fakeroot won't explode if
# ran from a nonexistent dir
spawn_opts["cwd"] = e_const.EAPI_BIN_PATH
- # little trick. we force the pipes to be high up fd wise so
- # nobody stupidly hits 'em.
+ # Force the pipes to be high up fd wise so nobody stupidly hits 'em, we
+ # start from max-3 to avoid a bug in older bash where it doesn't check
+ # if an fd is in use before claiming it.
max_fd = min(pkgcore.spawn.max_fd_limit, 1024)
env.update({
- "PKGCORE_EBD_READ_FD": str(max_fd-2),
- "PKGCORE_EBD_WRITE_FD": str(max_fd-1)})
+ "PKGCORE_EBD_READ_FD": str(max_fd-4),
+ "PKGCORE_EBD_WRITE_FD": str(max_fd-3)})
# pgid=0: Each ebuild processor is the process group leader for all its
# spawned children so everything can be terminated easily if necessary.
self.pid = spawn_func(
[const.BASH_BINARY, self.ebd, "daemonize"],
- fd_pipes={0: 0, 1: 1, 2: 2, max_fd-2: cread, max_fd-1: dwrite},
+ fd_pipes={0: 0, 1: 1, 2: 2, max_fd-4: cread, max_fd-3: dwrite},
returnpid=True, env=env, pgid=0, *args, **spawn_opts)[0]
os.close(cread)