diff options
author | Russel Winder <russel@winder.org.uk> | 2012-08-29 20:00:36 (GMT) |
---|---|---|
committer | Russel Winder <russel@winder.org.uk> | 2012-08-29 20:00:36 (GMT) |
commit | 8d266ff2aa3fb3dbb989d2a5c39e8769b0e989f8 (patch) | |
tree | 92584f7bce2320c60a9792907c8c08a6dde1780f /src | |
parent | 86ad443acfa0e3b3588fb3bc30770b3ed58c10fb (diff) | |
parent | a54670d821ac18abc3880ef9ca03c2f84edd5ae6 (diff) | |
download | SCons-8d266ff2aa3fb3dbb989d2a5c39e8769b0e989f8.zip SCons-8d266ff2aa3fb3dbb989d2a5c39e8769b0e989f8.tar.gz SCons-8d266ff2aa3fb3dbb989d2a5c39e8769b0e989f8.tar.bz2 |
Merge in the mainline.
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 9 | ||||
-rw-r--r-- | src/engine/SCons/Platform/win32.py | 25 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 685430c..01a2aa2 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -11,6 +11,15 @@ RELEASE 2.X.X - + From Thomas Berg and Evgeny Podjachev: + - Fix subprocess spawning on Windows. Work around a Windows + bug that can crash python occasionally when using -jN. (#2449) + + From Dirk Baechle: + - Updated test framework to support dir and file fixtures and + added ability to test external (out-of-tree) tools. + See doc in QMTest/test-framework.rst. + From Gary Oberbrunner: - Fix MSVS solution generation for VS11, and fixed tests. diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py index 664969a..c81eecf 100644 --- a/src/engine/SCons/Platform/win32.py +++ b/src/engine/SCons/Platform/win32.py @@ -36,6 +36,7 @@ import os import os.path import sys import tempfile +import threading from SCons.Platform.posix import exitvalmap from SCons.Platform import TempFileMunge @@ -81,7 +82,27 @@ else: builtins.file = _scons_file builtins.open = _scons_open +spawn_lock = threading.Lock() +# This locked version of spawnve works around a Windows +# MSVCRT bug, because its spawnve is not thread-safe. +# Without this, python can randomly crash while using -jN. +# See the python bug at http://bugs.python.org/issue6476 +# and SCons issue at +# http://scons.tigris.org/issues/show_bug.cgi?id=2449 +def spawnve(mode, file, args, env): + spawn_lock.acquire() + try: + if mode == os.P_WAIT: + ret = os.spawnve(os.P_NOWAIT, file, args, env) + else: + ret = os.spawnve(mode, file, args, env) + finally: + spawn_lock.release() + if mode == os.P_WAIT: + pid, status = os.waitpid(ret, 0) + ret = status >> 8 + return ret # The upshot of all this is that, if you are using Python 1.5.2, # you had better have cmd or command.com in your PATH when you run @@ -123,7 +144,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): # actually do the spawn try: args = [sh, '/C', escape(' '.join(args)) ] - ret = os.spawnve(os.P_WAIT, sh, args, env) + ret = spawnve(os.P_WAIT, sh, args, env) except OSError, e: # catch any error try: @@ -151,7 +172,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr): def exec_spawn(l, env): try: - result = os.spawnve(os.P_WAIT, l[0], l, env) + result = spawnve(os.P_WAIT, l[0], l, env) except OSError, e: try: result = exitvalmap[e[0]] |