summaryrefslogtreecommitdiffstats
path: root/pym/portage.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-26 04:28:14 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-26 04:28:14 +0000
commit5e47ba9550885a80d54fa0eff4f4ef67246960bd (patch)
tree88bff24e6efcbcff94cf29880df412af913d544f /pym/portage.py
parent7296a1443316d2ab09aa993ad5be69c3bb953c19 (diff)
downloadportage-5e47ba9550885a80d54fa0eff4f4ef67246960bd.tar.gz
portage-5e47ba9550885a80d54fa0eff4f4ef67246960bd.tar.bz2
portage-5e47ba9550885a80d54fa0eff4f4ef67246960bd.zip
Flush stderr and stdout if their file descriptors are in fd_pipes
at the beginning of spawn(). (trunk r7793:7796) svn path=/main/branches/2.1.2/; revision=7824
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pym/portage.py b/pym/portage.py
index bc3b72411..47d204b63 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -2343,6 +2343,18 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
env=mysettings.environ()
keywords["opt_name"]="[%s]" % mysettings["PF"]
+ fd_pipes = keywords.get("fd_pipes")
+ if fd_pipes is None:
+ fd_pipes = {0:0, 1:1, 2:2}
+ # In some cases the above print statements don't flush stdout, so
+ # it needs to be flushed before allowing a child process to use it
+ # so that output always shows in the correct order.
+ for fd in fd_pipes.itervalues():
+ if fd == sys.stdout.fileno():
+ sys.stdout.flush()
+ if fd == sys.stderr.fileno():
+ sys.stderr.flush()
+
# The default policy for the sesandbox domain only allows entry (via exec)
# from shells and from binaries that belong to portage (the number of entry
# points is minimized). The "tee" binary is not among the allowed entry
@@ -2356,10 +2368,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
got_pty = False
if logfile:
del keywords["logfile"]
- fd_pipes = keywords.get("fd_pipes")
- if fd_pipes is None:
- fd_pipes = {0:0, 1:1, 2:2}
- elif 1 not in fd_pipes or 2 not in fd_pipes:
+ if 1 not in fd_pipes or 2 not in fd_pipes:
raise ValueError(fd_pipes)
from pty import openpty
try: