Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion btest-bg-run-helper
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
22 changes: 22 additions & 0 deletions btest-bg-wait
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
Loading