diff options
author | Franck Bui <fbui@suse.com> | 2024-02-08 16:11:21 +0100 |
---|---|---|
committer | Franck Bui <fbui@suse.com> | 2024-02-09 18:07:08 +0100 |
commit | 14265c3360b02191975654981715584227c0650e (patch) | |
tree | 0060ed5029b358a15be30b909db1d0a8022161da /test/test-shutdown.py | |
parent | resolve: include interface name in org.freedesktop.resolve1 polkit checks (diff) | |
download | systemd-14265c3360b02191975654981715584227c0650e.tar.xz systemd-14265c3360b02191975654981715584227c0650e.zip |
test-69: send SIGTERM to ask systemd-nspawn to properly stop the container
The terminate() method sends SIGHUP but this signal is not handled by
systemd-nspawn hence the process just exits leaving the container scope around
breaking futher test executions.
This patch sends SIGTERM instead which is a defined API to request
sytemd-nspawn to stop and release the container's resources properly.
Follow-up for 8a7032cfb108c6daa395686320d9361c2195860a.
Diffstat (limited to 'test/test-shutdown.py')
-rwxr-xr-x | test/test-shutdown.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/test/test-shutdown.py b/test/test-shutdown.py index 5339afcdd0..e491f1e1a9 100755 --- a/test/test-shutdown.py +++ b/test/test-shutdown.py @@ -4,6 +4,7 @@ import argparse import logging +import signal import sys import time @@ -91,13 +92,10 @@ def run(args): except Exception as e: logger.error(e) logger.info("killing child pid %d", console.pid) - # We can't use console.terminate(force=True) right away, since - # the internal delay between sending a signal and checking the process - # is just 0.1s [0], which means we'd get SIGKILLed pretty quickly. - # Let's send SIGHUP/SIGINT first, wait a bit, and then follow-up with - # SIGHUP/SIGINT/SIGKILL if the process is still alive. - # [0] https://github.com/pexpect/pexpect/blob/acb017a97332c19a9295660fe87316926a8adc55/pexpect/spawnbase.py#L71 - console.terminate() + + # Ask systemd-nspawn to stop and release the container's resources properly. + console.kill(signal.SIGTERM) + for _ in range(10): if not console.isalive(): break |