[cfe-commits] r65075 - /cfe/trunk/tools/ccc/ccclib/Driver.py
Daniel Dunbar
daniel at zuster.org
Thu Feb 19 14:59:57 PST 2009
Author: ddunbar
Date: Thu Feb 19 16:59:57 2009
New Revision: 65075
URL: http://llvm.org/viewvc/llvm-project?rev=65075&view=rev
Log:
ccc: Give nicer error when spawning a subprocess fails.
Modified:
cfe/trunk/tools/ccc/ccclib/Driver.py
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=65075&r1=65074&r2=65075&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Thu Feb 19 16:59:57 2009
@@ -1,5 +1,6 @@
import os
import platform
+import subprocess
import sys
import tempfile
from pprint import pprint
@@ -224,11 +225,12 @@
if vArg or self.cccEcho:
print >>sys.stderr, ' '.join(map(str,j.getArgv()))
sys.stderr.flush()
- res = os.spawnvp(os.P_WAIT, j.executable, j.getArgv())
+ p = self.startSubprocess(j.getArgv(), j.executable)
+ res = p.wait()
if res:
sys.exit(res)
+
elif isinstance(j, Jobs.PipedJob):
- import subprocess
procs = []
for sj in j.commands:
if vArg or self.cccEcho:
@@ -243,10 +245,11 @@
stdout = None
else:
stdout = subprocess.PIPE
- procs.append(subprocess.Popen(sj.getArgv(),
- executable=sj.executable,
- stdin=stdin,
- stdout=stdout))
+
+ procs.append(self.startSubprocess(sj.getArgv(), sj.executable,
+ stdin=stdin,
+ stdout=stdout))
+
for proc in procs:
res = proc.wait()
if res:
@@ -254,6 +257,14 @@
else:
raise ValueError,'Encountered unknown job.'
+ def startSubprocess(self, argv, executable, **kwargs):
+ try:
+ return subprocess.Popen(argv, executable=executable, **kwargs)
+ except OSError, e:
+ self.warning("error trying to exec '%s': %s" %
+ (executable, e.args[1]))
+ sys.exit(1)
+
def claim(self, option):
# FIXME: Move to OptionList once introduced and implement.
pass
More information about the cfe-commits
mailing list