summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-17 04:20:12 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-17 04:20:12 +0000
commit4d1eb74f1ccce825c7f3fdbb947d278fd61b12b5 (patch)
tree4ff7a436717fbb3258ee0b16d4dd945b43fcba13
parentEliminate duplicate code by making EbuildProcess inherit from SpawnProcess (diff)
downloadportage-multirepo-4d1eb74f1ccce825c7f3fdbb947d278fd61b12b5.tar.gz
portage-multirepo-4d1eb74f1ccce825c7f3fdbb947d278fd61b12b5.tar.bz2
portage-multirepo-4d1eb74f1ccce825c7f3fdbb947d278fd61b12b5.zip
When SpawnProcess._start() spawns a process in the background, use /dev/null
so that any attempts to read from stdin will immediately return EOF instead of blocking indefinitely. TODO: Use job control functions like tcsetpgrp() to control access to stdin. svn path=/main/trunk/; revision=11093
-rw-r--r--pym/_emerge/__init__.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 1373d3ab..13df0d8f 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -2045,11 +2045,21 @@ class SpawnProcess(SubProcess):
fcntl.fcntl(master_fd, fcntl.F_SETFL,
fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+ null_input = None
+ fd_pipes_orig = fd_pipes.copy()
+ if self.background:
+ # TODO: Use job control functions like tcsetpgrp() to control
+ # access to stdin. Until then, use /dev/null so that any
+ # attempts to read from stdin will immediately return EOF
+ # instead of blocking indefinitely.
+ null_input = open('/dev/null', 'rb')
+ fd_pipes[0] = null_input.fileno()
+ else:
+ fd_pipes[0] = fd_pipes_orig[0]
+
files.process = os.fdopen(master_fd, 'r')
if logfile is not None:
- fd_pipes_orig = fd_pipes.copy()
- fd_pipes[0] = fd_pipes_orig[0]
fd_pipes[1] = slave_fd
fd_pipes[2] = slave_fd
@@ -2086,6 +2096,8 @@ class SpawnProcess(SubProcess):
retval = self._spawn(self.args, **kwargs)
os.close(slave_fd)
+ if null_input is not None:
+ null_input.close()
if isinstance(retval, int):
# spawn failed