mirror of
https://github.com/gosticks/RIOT.git
synced 2026-10-06 07:47:09 +00:00
testrunner: use SIGKILL only as last resort
When the child has a clean-up step (closing files, killing sub-processes, deleting operational files, etc.), this currently is not executed by the test, as the `testrunner` just does a hard `SIGKILL` for the child's PPID. This change makes this a `SIGTERM` and only uses `SIGKILL` if there are still processes lingering a second after the `SIGTERM`.
This commit is contained in:
Vendored
+10
-2
@@ -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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user