SpawnProcess: stdout_fd FD_CLOEXEC
authorZac Medico <zmedico@gentoo.org>
Tue, 8 Jan 2013 02:08:40 +0000 (18:08 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 Jan 2013 02:09:48 +0000 (18:09 -0800)
pym/_emerge/SpawnProcess.py

index 293e5be8c14968c48f0a9723832708ae343a2995..f226dcb8f03c444b292841dfd2abb0cd05b1effd 100644 (file)
@@ -1,6 +1,12 @@
 # Copyright 2008-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+try:
+       import fcntl
+except ImportError:
+       # http://bugs.jython.org/issue1074
+       fcntl = None
+
 from _emerge.SubProcess import SubProcess
 import sys
 import portage
@@ -105,6 +111,15 @@ 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:
+                               try:
+                                       fcntl.FD_CLOEXEC
+                               except AttributeError:
+                                       pass
+                               else:
+                                       fcntl.fcntl(stdout_fd, fcntl.F_SETFL,
+                                               fcntl.fcntl(stdout_fd,
+                                               fcntl.F_GETFL) | fcntl.FD_CLOEXEC)
 
                self._pipe_logger = PipeLogger(background=self.background,
                        scheduler=self.scheduler, input_fd=master_fd,