summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-22 18:54:46 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-22 18:54:46 +0000
commit7c27bcd86c26d821952ea9c16189f95e376a71dc (patch)
tree92f11377f6f1e697b48e377c8761dfc79484d24a
parentd204f56015eba60cb7f219ecce54d730b3e18051 (diff)
downloadportage-7c27bcd86c26d821952ea9c16189f95e376a71dc.tar.gz
portage-7c27bcd86c26d821952ea9c16189f95e376a71dc.tar.bz2
portage-7c27bcd86c26d821952ea9c16189f95e376a71dc.zip
Flush stderr and stdout if their file descriptors are in fd_pipes at the beginning of spawn().
svn path=/main/trunk/; revision=7795
-rw-r--r--pym/emerge/__init__.py4
-rw-r--r--pym/portage/__init__.py10
2 files changed, 10 insertions, 4 deletions
diff --git a/pym/emerge/__init__.py b/pym/emerge/__init__.py
index d11143d26..652a3d355 100644
--- a/pym/emerge/__init__.py
+++ b/pym/emerge/__init__.py
@@ -5400,10 +5400,6 @@ def action_info(settings, trees, myopts, myfiles):
if not ebuildpath or not os.path.exists(ebuildpath):
out.ewarn("No ebuild found for '%s'" % pkg)
continue
- # 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.
- sys.stdout.flush()
portage.doebuild(ebuildpath, "info", pkgsettings["ROOT"],
pkgsettings, debug=(settings.get("PORTAGE_DEBUG", "") == 1),
mydbapi=trees[settings["ROOT"]]["vartree"].dbapi,
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index e11b8f419..271e11669 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -2385,6 +2385,16 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
env=mysettings.environ()
keywords["opt_name"]="[%s]" % mysettings["PF"]
+ # 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.
+ fd_pipes = keywords.get("fd_pipes")
+ if fd_pipes:
+ if fd_pipes.get(1) == sys.stdout.fileno():
+ sys.stdout.flush()
+ if fd_pipes.get(2) == 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