diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-02-19 22:59:57 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-02-19 22:59:57 +0000 |
| commit | 2a07da78c0269c1f737d12cdf638e44d0d9992fe (patch) | |
| tree | 2750ac409cc51aa04ecd070364408ca29482f8cf | |
| parent | 1c8560d93ef3ae8d4fded9d355b27d53f5b04e8c (diff) | |
| download | bcm5719-llvm-2a07da78c0269c1f737d12cdf638e44d0d9992fe.tar.gz bcm5719-llvm-2a07da78c0269c1f737d12cdf638e44d0d9992fe.zip | |
ccc: Give nicer error when spawning a subprocess fails.
llvm-svn: 65075
| -rw-r--r-- | clang/tools/ccc/ccclib/Driver.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/clang/tools/ccc/ccclib/Driver.py b/clang/tools/ccc/ccclib/Driver.py index 43e145b9dbe..fb69193be87 100644 --- a/clang/tools/ccc/ccclib/Driver.py +++ b/clang/tools/ccc/ccclib/Driver.py @@ -1,5 +1,6 @@ import os import platform +import subprocess import sys import tempfile from pprint import pprint @@ -224,11 +225,12 @@ class Driver(object): 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 @@ class Driver(object): 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 @@ class Driver(object): 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 |

