Flush stderr and stdout if their file descriptors are in fd_pipes at the beginning...
authorZac Medico <zmedico@gentoo.org>
Sat, 22 Sep 2007 18:54:46 +0000 (18:54 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 22 Sep 2007 18:54:46 +0000 (18:54 -0000)
svn path=/main/trunk/; revision=7795

pym/emerge/__init__.py
pym/portage/__init__.py

index d11143d269f2bf69f90e847db6fab0b1737b8356..652a3d355835ce567414effd249c2cd0a7b42b52 100644 (file)
@@ -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,
index e11b8f41979efe9d2abcc375e37414a1f5c68c14..271e116691b888964608756db8db950dd51f8201 100644 (file)
@@ -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