42e3442739
See http://bugs.python.org/issue1731717 for addition details SCon's compat/_scons_subprocess.py module is just a copy of a more recent stock Python subprocess.py modified so it will work with older Python versions. The attached patch will add locks around calls to Popen and change the compat module in a way that the subprocess module is always used, no matter if Python already ships one. The rationale behind this decision is that there are many Python versions in the wild with different Popen() race condition problems. PR: ports/128845 Submitted by: Steven Kreuzer <skreuzer@exit2shell.com> Approved by: araujo (mentor, implicit)
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
Index: engine/SCons/compat/_scons_subprocess.py
|
|
===================================================================
|
|
--- engine/SCons/compat/_scons_subprocess.py (revision 2695)
|
|
+++ engine/SCons/compat/_scons_subprocess.py (working copy)
|
|
@@ -581,13 +581,19 @@
|
|
class object:
|
|
pass
|
|
|
|
+import thread
|
|
+lock = thread.allocate_lock()
|
|
+
|
|
class Popen(object):
|
|
def __init__(self, args, bufsize=0, executable=None,
|
|
stdin=None, stdout=None, stderr=None,
|
|
preexec_fn=None, close_fds=False, shell=False,
|
|
cwd=None, env=None, universal_newlines=False,
|
|
startupinfo=None, creationflags=0):
|
|
- """Create new Popen instance."""
|
|
+ """Create new Popen instance.
|
|
+ Popen is not thread-safe and is therefore protected with a lock.
|
|
+ """
|
|
+ lock.acquire()
|
|
_cleanup()
|
|
|
|
self._child_created = False
|
|
@@ -655,6 +661,7 @@
|
|
self.stderr = os.fdopen(errread, 'rU', bufsize)
|
|
else:
|
|
self.stderr = os.fdopen(errread, 'rb', bufsize)
|
|
+ lock.release()
|
|
|
|
|
|
def _translate_newlines(self, data):
|