From: Frantisek Sumsal Date: Thu, 21 Oct 2021 13:59:57 +0000 (+0200) Subject: test: wait a bit for the given PID to die if it's still alive X-Git-Tag: v250-rc1~454^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dded88acb9320e3f16a97073c84a139a56e0def5;p=thirdparty%2Fsystemd.git test: wait a bit for the given PID to die if it's still alive When playing around with the coverage-enabled build I kept hitting an issue where dnsmasq failed to start because the previous instance was still shutting down. This should, hopefully, help to mitigate that. --- diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 733a8d5aa55..4a358edcd27 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3,6 +3,7 @@ # systemd-networkd tests import argparse +import errno import itertools import os import re @@ -483,6 +484,15 @@ def stop_by_pid_file(pid_file): with open(pid_file, 'r') as f: pid = f.read().rstrip(' \t\r\n\0') os.kill(int(pid), signal.SIGTERM) + for _ in range(25): + try: + os.kill(int(pid), 0) + print(f"PID {pid} is still alive, waiting...") + time.sleep(.2) + except OSError as e: + if e.errno == errno.ESRCH: + break + print(f"Unexpected exception when waiting for {pid} to die: {e.errno}") os.remove(pid_file)