SubProcess: re-organize Darwin/fcntl logic
authorZac Medico <zmedico@gentoo.org>
Sat, 23 Mar 2013 23:00:17 +0000 (16:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 23 Mar 2013 23:00:17 +0000 (16:00 -0700)
pym/_emerge/SpawnProcess.py

index c54988446b623a037571cded675ca2009a3177c6..25859a9cd4449f6e0dab81732dcd5ffb92d64bfe 100644 (file)
@@ -7,18 +7,17 @@ except ImportError:
        # http://bugs.jython.org/issue1074
        fcntl = None
 
-from _emerge.SubProcess import SubProcess
+import platform
 import sys
+
+from _emerge.SubProcess import SubProcess
 import portage
 from portage import os
 from portage.const import BASH_BINARY
 from portage.util._async.PipeLogger import PipeLogger
 
-# https://bugs.gentoo.org/show_bug.cgi?id=456296
-import platform
-if platform.system() in ("Darwin",):
-    # disable FD_CLOEXEC on stdout, breaks horribly
-    fcntl = None
+# On Darwin, FD_CLOEXEC triggers errno 35 for stdout (bug #456296)
+_disable_cloexec_stdout = platform.system() in ("Darwin",)
 
 class SpawnProcess(SubProcess):
 
@@ -120,7 +119,7 @@ class SpawnProcess(SubProcess):
                stdout_fd = None
                if can_log and not self.background:
                        stdout_fd = os.dup(fd_pipes_orig[1])
-                       if fcntl is not None:
+                       if fcntl is not None and not _disable_cloexec_stdout:
                                try:
                                        fcntl.FD_CLOEXEC
                                except AttributeError: