Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2394)

Unified Diff: dart/tools/testing/drt-trampoline.py

Issue 10834363: Install a signal handler to ensure drt-trampoline.py cleans up after itself. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add a few comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tools/testing/drt-trampoline.py
diff --git a/dart/tools/testing/drt-trampoline.py b/dart/tools/testing/drt-trampoline.py
index 130096c92dec9d6600f31efca3eb01e879297391..33fc16ad7f1abe09909d3e447817fbb988318bb8 100644
--- a/dart/tools/testing/drt-trampoline.py
+++ b/dart/tools/testing/drt-trampoline.py
@@ -9,6 +9,7 @@
# Expected invocation: python drt-trampoline.py <path to DRT> <DRT command line>
import os
+import signal
import subprocess
import sys
@@ -53,7 +54,19 @@ def main(argv):
stdout = subprocess.PIPE if out_expected_file else None
p = subprocess.Popen(cmd, env=env, stdout=stdout)
+
+ def signal_handler(signal, frame):
+ p.terminate()
+ sys.exit(0)
+
+ # SIGINT is Ctrl-C.
+ signal.signal(signal.SIGINT, signal_handler)
+ # SIGTERM is sent by test.dart when a process times out.
+ signal.signal(signal.SIGTERM, signal_handler)
output, error = p.communicate()
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
if p.returncode != 0:
raise Exception('Failed to run command. return code=%s' % p.returncode)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698