Browse Source

Tools: autotest: send SIGTERM to processes before killing them

This allows coverage atexit functions to run
mission-4.1.18
Peter Barker 6 years ago committed by Peter Barker
parent
commit
03e317fed8
  1. 14
      Tools/autotest/pysim/util.py

14
Tools/autotest/pysim/util.py

@ -6,6 +6,7 @@ import os
import random import random
import re import re
import shlex import shlex
import signal
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
@ -165,6 +166,19 @@ def pexpect_close(p):
"""Close a pexpect child.""" """Close a pexpect child."""
global close_list global close_list
ex = None
try:
p.kill(signal.SIGTERM)
except IOError as e:
print("Caught exception: %s" % str(e))
ex = e
pass
if ex is None:
# give the process some time to go away
for i in range(20):
if not p.isalive():
break
time.sleep(0.05)
try: try:
p.close() p.close()
except Exception: except Exception:

Loading…
Cancel
Save