From b21f8677ceded01df4cf855b1c6bcb3faa1f86df Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 22 Apr 2026 17:30:33 +0000 Subject: [PATCH] fix(marmot-interop): clean up daemons on Ctrl+C / SIGTERM / SIGHUP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous trap only fired on the EXIT pseudo-signal, which doesn't always run cleanly when the script is killed mid-flight — leaving the nohup'd wnd daemons (and the local relay) alive and still holding the port. Route SIGINT/SIGTERM/SIGHUP through an explicit `exit`, use a single idempotent cleanup handler, and preserve the exit code so the harness still reports failure when killed. --- tools/marmot-interop/marmot-interop-headless.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/marmot-interop/marmot-interop-headless.sh b/tools/marmot-interop/marmot-interop-headless.sh index bd6ac542d..df2bd8308 100755 --- a/tools/marmot-interop/marmot-interop-headless.sh +++ b/tools/marmot-interop/marmot-interop-headless.sh @@ -80,7 +80,22 @@ source "$SCRIPT_DIR/headless/tests-manage.sh" # shellcheck source=headless/tests-extras.sh source "$SCRIPT_DIR/headless/tests-extras.sh" -trap 'stop_daemons; stop_local_relay; print_summary' EXIT +# Make sure Ctrl+C / SIGTERM / SIGHUP all run the full cleanup path — +# otherwise wnd is nohup'd and keeps running after the script dies, +# and the next run's `ss` check then complains the port is in use. +# Trap INT/TERM/HUP forces `exit`, which triggers the EXIT handler once. +cleanup() { + local rc=$? + trap - EXIT INT TERM HUP + stop_daemons + stop_local_relay + print_summary + exit "$rc" +} +trap cleanup EXIT +trap 'exit 130' INT +trap 'exit 143' TERM +trap 'exit 129' HUP banner "Marmot headless interop harness ($RUN_TS)" preflight