diff options
author | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 22:31:16 +0000 |
---|---|---|
committer | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 22:31:16 +0000 |
commit | 50461c2a587ec8a883c1a61a49e0506a464faffc (patch) | |
tree | 159175043a589ee26661019437634ff316a7b3aa /tools | |
parent | 52bd99fd4282ce282331d0bf7c86e6ab886d148a (diff) | |
download | chromium_src-50461c2a587ec8a883c1a61a49e0506a464faffc.zip chromium_src-50461c2a587ec8a883c1a61a49e0506a464faffc.tar.gz chromium_src-50461c2a587ec8a883c1a61a49e0506a464faffc.tar.bz2 |
Fix timeout when not detached
Also fix how timeout kills subprocess on Linux and Mac
Review URL: http://codereview.chromium.org/115042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15466 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r-- | tools/purify/common.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/purify/common.py b/tools/purify/common.py index 102c4af6..ea039e8 100644 --- a/tools/purify/common.py +++ b/tools/purify/common.py @@ -29,6 +29,7 @@ import datetime import logging import optparse import os +import signal import subprocess import sys import tempfile @@ -68,7 +69,8 @@ def RunSubprocess(proc, timeout=0, detach=False): on Windows. This is used by Purify subprocesses on buildbot which seem to get confused by the parent console that buildbot sets up. """ - logging.info("running %s" % (" ".join(proc))) + + logging.info("running %s, timeout %d sec" % (" ".join(proc), timeout)) if detach: # see MSDN docs for "Process Creation Flags" DETACHED_PROCESS = 0x8 @@ -94,9 +96,11 @@ def RunSubprocess(proc, timeout=0, detach=False): while p.poll() is None and not did_timeout: if not detach: line = p.stdout.readline() - while line: + while line and not did_timeout: _print_line(line) line = p.stdout.readline() + if timeout > 0: + did_timeout = time.time() > wait_until else: # When we detach, blocking on reading stdout doesn't work, so we sleep # a short time and poll. @@ -118,7 +122,11 @@ def RunSubprocess(proc, timeout=0, detach=False): logging.info("process ended, did not time out") if did_timeout: - subprocess.call(["taskkill", "/T", "/F", "/PID", str(p.pid)]) + if sys.platform == "win32": + subprocess.call(["taskkill", "/T", "/F", "/PID", str(p.pid)]) + else: + # Does this kill all children, too? + os.kill(p.pid, signal.SIGINT) logging.error("KILLED %d" % p.pid) # Give the process a chance to actually die before continuing # so that cleanup can happen safely. @@ -325,7 +333,7 @@ class Rational(object): logging.info("clearing instrumentation cache %s" % self._cache_dir) if os.path.isdir(self._cache_dir): for cfile in os.listdir(self._cache_dir): - file = os.path.join(self._cache_dir, cfile); + file = os.path.join(self._cache_dir, cfile) if os.path.isfile(file): try: os.remove(file) |