summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2012-08-29 00:27:34 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2012-08-29 00:27:34 (GMT)
commit0aca78d2920123b7b9d95126b304f1aaab0c2b93 (patch)
tree0129ffec29318f72034cd4933eece2f0815d2bf8
parentb735a9289ae90b3284da18433f0348bab1636fd0 (diff)
parent76845767d1945dbccc77ceb5fd4337147a7feb4c (diff)
downloadSCons-0aca78d2920123b7b9d95126b304f1aaab0c2b93.zip
SCons-0aca78d2920123b7b9d95126b304f1aaab0c2b93.tar.gz
SCons-0aca78d2920123b7b9d95126b304f1aaab0c2b93.tar.bz2
Merge pull request #34, fix spawn on Windows, from Evgeny Podjachev.
-rw-r--r--src/CHANGES.txt4
-rw-r--r--src/engine/SCons/Platform/win32.py19
2 files changed, 21 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 71429f9..51eb505 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -6,6 +6,10 @@
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.
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
index 664969a..ff91bf9 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,21 @@ else:
builtins.file = _scons_file
builtins.open = _scons_open
+spawn_lock = threading.Lock()
+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 +138,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 +166,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]]