Merge pull request #13891 from miri64/testrunner/fix/SIGKILL-last-resort

testrunner: use SIGKILL only as last resort
This commit is contained in:
Leandro Lanzieri 2020-04-28 20:15:00 +02:00 committed by GitHub
commit fe09fd3502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,11 +89,19 @@ def setup_child(timeout=10, spawnclass=pexpect.spawnu, env=None, logfile=None):
def teardown_child(child):
pid = child.pid
try:
os.killpg(os.getpgid(child.pid), signal.SIGKILL)
os.killpg(os.getpgid(pid), signal.SIGTERM)
except ProcessLookupError:
print("Process already stopped")
else:
time.sleep(1)
# kill still lingering processes
try:
os.killpg(os.getpgid(pid), signal.SIGKILL)
except ProcessLookupError:
# This is what we actually wanted
pass
child.close()