summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/_MergeProcess.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-02-14 04:29:02 -0800
committerZac Medico <zmedico@gentoo.org>2012-02-14 04:29:02 -0800
commita75341bf3a66f75edd68d1a8bc5efdb51c0c0740 (patch)
tree731f6f1bb4840d83b128d4401b052a8377818961 /pym/portage/dbapi/_MergeProcess.py
parentfe3960b69c326bc779bdf5ec34d56630b3e188ae (diff)
downloadportage-a75341bf3a66f75edd68d1a8bc5efdb51c0c0740.tar.gz
portage-a75341bf3a66f75edd68d1a8bc5efdb51c0c0740.tar.bz2
portage-a75341bf3a66f75edd68d1a8bc5efdb51c0c0740.zip
After python fork, don't close fds for PyPy 1.8.
If we close all open file descriptors after a fork, with PyPy 1.8 it triggers "[Errno 9] Bad file descriptor" later in the subprocess. Apparently it is holding references to file descriptors and closing them after they've already been closed and re-opened for other purposes. As a workaround, we don't close the file descriptors, so that they won't be re-used and therefore we won't be vulnerable to this kind of interference. The obvious caveat of not closing the fds is that the subprocess can hold locks that belonged to the parent process, even after the parent process has released the locks. Hopefully this won't be a major problem though, since the subprocess has to exit at release the lock eventually, when the EbuildFetcher or _MergeProcess task is complete.
Diffstat (limited to 'pym/portage/dbapi/_MergeProcess.py')
-rw-r--r--pym/portage/dbapi/_MergeProcess.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
index 9bb67c9b6..cf5926529 100644
--- a/pym/portage/dbapi/_MergeProcess.py
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
import io
+import platform
import signal
import traceback
@@ -143,7 +144,11 @@ class MergeProcess(SpawnProcess):
return [pid]
os.close(elog_reader_fd)
- portage.process._setup_pipes(fd_pipes)
+
+ # TODO: Find out why PyPy 1.8 with close_fds=True triggers
+ # "[Errno 9] Bad file descriptor" in subprocesses.
+ close_fds = platform.python_implementation() != 'PyPy'
+ portage.process._setup_pipes(fd_pipes, close_fds=close_fds)
# Use default signal handlers since the ones inherited
# from the parent process are irrelevant here.