Index: subprocess2.py |
diff --git a/subprocess2.py b/subprocess2.py |
index d59035b4878f008e8c7b1596cc4aefdebb67f947..9aefeea45702ca2ab177593539acf4ab1c240991 100644 |
--- a/subprocess2.py |
+++ b/subprocess2.py |
@@ -7,6 +7,7 @@ |
In theory you shouldn't need anything else in subprocess, or this module failed. |
""" |
+import errno |
import logging |
import os |
import subprocess |
@@ -79,7 +80,7 @@ def get_english_env(env): |
def Popen(args, **kwargs): |
- """Wraps subprocess.Popen(). |
+ """Wraps subprocess.Popen() with various workarounds. |
Forces English output since it's easier to parse the stdout if it is always in |
English. |
@@ -87,7 +88,8 @@ def Popen(args, **kwargs): |
Sets shell=True on windows by default. You can override this by forcing shell |
parameter to a value. |
- Popen() can throw OSError when cwd or args[0] doesn't exist. |
+ Popen() can throw OSError when cwd or args[0] doesn't exist. Translate |
+ exceptions generated by cygwin when it fails trying to emulate fork(). |
""" |
# Make sure we hack subprocess if necessary. |
hack_subprocess() |
@@ -106,7 +108,20 @@ def Popen(args, **kwargs): |
if kwargs.get('cwd', None): |
tmp_str += '; cwd=%s' % kwargs['cwd'] |
logging.debug(tmp_str) |
- return subprocess.Popen(args, **kwargs) |
+ try: |
+ return subprocess.Popen(args, **kwargs) |
+ except OSError, e: |
+ if e.errno == errno.EAGAIN and sys.platform == 'cygwin': |
+ # Convert fork() emulation failure into a CalledProcessError(). |
+ raise CalledProcessError( |
+ e.errno, |
+ args, |
+ kwargs.get('cwd'), |
+ 'Visit ' |
+ 'http://code.google.com/p/chromium/wiki/CygwinDllRemappingFailure to ' |
+ 'learn how to fix this error; you need to rebase your cygwin dlls', |
+ None) |
+ raise |
def call(args, timeout=None, **kwargs): |