Skip to content

Commit 2a4a02c

Browse files
authored
Merge pull request #1944 from mbedmicro/ctrl-c-traceback
Fixes the python traceback when the user does ctrl+c during compilation
2 parents 1bdd45c + edc1fa1 commit 2a4a02c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/toolchains/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
def compile_worker(job):
4242
results = []
4343
for command in job['commands']:
44-
_, _stderr, _rc = run_cmd(command, job['work_dir'])
44+
try:
45+
_, _stderr, _rc = run_cmd(command, job['work_dir'])
46+
except KeyboardInterrupt as e:
47+
raise ToolException
48+
4549
results.append({
4650
'code': _rc,
4751
'output': _stderr,

tools/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ def run_cmd(command, wd=None, redirect=False):
3838
try:
3939
p = Popen(command, stdout=PIPE, stderr=STDOUT if redirect else PIPE, cwd=wd)
4040
_stdout, _stderr = p.communicate()
41-
except:
41+
except OSError as e:
4242
print "[OS ERROR] Command: "+(' '.join(command))
4343
raise
44+
4445
return _stdout, _stderr, p.returncode
4546

4647

0 commit comments

Comments
 (0)