Removed gclient_utils.Popen() and use subprocess2's version instead.
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/6770028
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@79779 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/subprocess2.py b/subprocess2.py
index d59035b..9aefeea 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 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 @@
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 @@
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):