From 316fba3343bb6492e5d971b192b7aa8dc29e961d Mon Sep 17 00:00:00 2001 From: Maor Hamami Date: Sun, 8 Mar 2026 12:09:15 +0200 Subject: [PATCH 1/2] [windows] wait for process kill before the next test --- btest-bg-wait | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/btest-bg-wait b/btest-bg-wait index ed06a00..d1a65c4 100755 --- a/btest-bg-wait +++ b/btest-bg-wait @@ -72,6 +72,7 @@ function kill_procs { # processes and their descendants are terminated even if # MSYS signals did not reach them. if [ $is_windows -eq 1 ]; then + local msys_pids="" for p in $procs; do if [ -f "$p/.winpid" ]; then local wpid @@ -80,7 +81,28 @@ function kill_procs { MSYS_NO_PATHCONV=1 taskkill /F /T /PID "$wpid" &>/dev/null fi fi + if [ -f "$p/.pid" ]; then + msys_pids="$msys_pids $(cat "$p/.pid")" + fi done + + # Wait for killed processes to fully exit so that ports + # and file handles are released before the next test. + if [ -n "$msys_pids" ]; then + local attempts=0 + while [ $attempts -lt 20 ]; do + local any_alive=0 + for mpid in $msys_pids; do + if kill -0 "$mpid" 2>/dev/null; then + any_alive=1 + break + fi + done + [ $any_alive -eq 0 ] && break + sleep 0.1 + attempts=$((attempts + 1)) + done + fi fi } From 9805dc25a96fd5542af90ba51bb5ccb1fb1bc667 Mon Sep 17 00:00:00 2001 From: Maor Hamami Date: Mon, 9 Mar 2026 15:42:06 +0200 Subject: [PATCH 2/2] translate windows sigterm error code to 0 --- btest-bg-run-helper | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/btest-bg-run-helper b/btest-bg-run-helper index 63d982f..61688dc 100755 --- a/btest-bg-run-helper +++ b/btest-bg-run-helper @@ -68,5 +68,16 @@ if [ $is_windows -eq 1 ] && [ -f /proc/$pid/winpid ]; then fi wait $pid -echo $? >.exitcode +rc=$? + +# On Windows, TerminateProcess cannot invoke clean signal handlers the +# way Unix signals do. A process killed by SIGTERM exits with code 15, +# which bash maps to 128+15=143. When a test intentionally kills a +# process (e.g., supervisor shutdown), this is the expected outcome, so +# treat it as success. +if [ $is_windows -eq 1 ] && [ $rc -eq 143 ]; then + rc=0 +fi + +echo $rc >.exitcode pid=""