Skip to content

Commit 4d908f2

Browse files
committed
bash: avoid waiting on taskkilled jobs
1 parent dd51812 commit 4d908f2

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

test-wheel.bash

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,15 @@ terminate_pid_tree() {
5252

5353
if [[ "$is_windows_shell" == true ]] && command -v taskkill >/dev/null 2>&1; then
5454
taskkill //PID "$pid" //T //F >/dev/null 2>&1 || true
55-
else
56-
kill -TERM "-$pid" >/dev/null 2>&1 || kill "$pid" >/dev/null 2>&1 || true
55+
return 0
5756
fi
5857

58+
kill -TERM "-$pid" >/dev/null 2>&1 || kill "$pid" >/dev/null 2>&1 || true
59+
5960
local deadline=$((SECONDS + 20))
6061
while kill -0 "$pid" >/dev/null 2>&1; do
6162
if (( SECONDS >= deadline )); then
62-
if [[ "$is_windows_shell" == true ]] && command -v taskkill >/dev/null 2>&1; then
63-
taskkill //PID "$pid" //T //F >/dev/null 2>&1 || true
64-
else
65-
kill -KILL "-$pid" >/dev/null 2>&1 || kill -9 "$pid" >/dev/null 2>&1 || true
66-
fi
63+
kill -KILL "-$pid" >/dev/null 2>&1 || kill -9 "$pid" >/dev/null 2>&1 || true
6764
break
6865
fi
6966
sleep 1
@@ -95,6 +92,15 @@ launch_background_command() {
9592
cleanup_background_jobs() {
9693
local pid=""
9794
for pid in "${background_pids[@]:+${background_pids[@]}}"; do
95+
if [[ "$is_windows_shell" == true ]]; then
96+
if kill -0 "$pid" >/dev/null 2>&1; then
97+
terminate_pid_tree "$pid"
98+
else
99+
wait "$pid" 2>/dev/null || true
100+
fi
101+
continue
102+
fi
103+
98104
if kill -0 "$pid" >/dev/null 2>&1; then
99105
terminate_pid_tree "$pid"
100106
else

0 commit comments

Comments
 (0)