From 29dd18ddc52d6683489f0cde203eb2d43b2d8296 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 6 Jun 2026 15:30:47 +0200 Subject: [PATCH] tests: add SIGKILL fallback in cleanup_client_server Ensure that ocserv is killed within bounded time by falling back to a SIGKILL if ocserv does not stop on time. Signed-off-by: Nikos Mavrogiannopoulos --- tests/common.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/common.sh b/tests/common.sh index fb20febc..b1c83534 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -247,8 +247,17 @@ cleanup_client_server() { test -n "${CLIPID}" && test -f "${CLIPID}" && kill $(cat ${CLIPID}) >/dev/null 2>&1 test -n "${CLIPID}" && rm -f "${CLIPID}" >/dev/null 2>&1 sleep 2 - test -n "${PID}" && kill ${PID} >/dev/null 2>&1 - test -n "${PID}" && wait ${PID} 2>/dev/null + if test -n "${PID}"; then + kill ${PID} >/dev/null 2>&1 + # Wait up to 10 s for graceful exit; force-kill if main is stuck + # (e.g. blocked on a sec-mod IPC call during shutdown). + for _cleanup_i in $(seq 1 10); do + kill -0 "${PID}" 2>/dev/null || break + sleep 1 + done + kill -9 "${PID}" 2>/dev/null + wait ${PID} 2>/dev/null + fi test -n "${PIDFILE}" && rm -f "${PIDFILE}" >/dev/null 2>&1 test -n "${CONFIG}" && rm -f "${CONFIG}" >/dev/null 2>&1 }