# HG changeset patch # User Doug Simon # Date 1400687861 -7200 # Node ID 9acad98567dc5c9269ee85f513f4de50148488ff # Parent 4900010a15d2b89d3df6c54d914c79e79b863885 mx: fixed more spurious "error while killing subprocess" messages (GRAAL-350) diff -r 4900010a15d2 -r 9acad98567dc mxtool/mx.py --- a/mxtool/mx.py Wed May 21 16:41:57 2014 +0200 +++ b/mxtool/mx.py Wed May 21 17:57:41 2014 +0200 @@ -34,6 +34,7 @@ """ import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch +import multiprocessing import textwrap import socket import tarfile @@ -1844,14 +1845,22 @@ if _opts.killwithsigquit: _send_sigquit() + def is_alive(p): + if isinstance(p, subprocess.Popen): + return p.poll() is not None + assert isinstance(p, multiprocessing.Process), p + return p.is_alive() + for p, args in _currentSubprocesses: - try: - if get_os() == 'windows': - p.terminate() - else: - _kill_process_group(p.pid, signal.SIGKILL) - except BaseException as e: - log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) + if is_alive(p): + try: + if get_os() == 'windows': + p.terminate() + else: + _kill_process_group(p.pid, signal.SIGKILL) + except BaseException as e: + if is_alive(p): + log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) if _opts and _opts.verbose: import traceback @@ -2295,7 +2304,6 @@ t._d = None return sorted(tasks, compareTasks) - import multiprocessing cpus = multiprocessing.cpu_count() worklist = sortWorklist(tasks.values()) active = []