fix(playable): close release validation lifecycle gaps

This commit is contained in:
shen
2026-09-11 21:23:44 +08:00
parent f39a55fdd5
commit cc5573ddc1
13 changed files with 230 additions and 7 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Sourced by runners. Only signal children whose PIDs this runner still owns.
# Clear each PID immediately after wait, so EXIT cannot signal a reused PID.
child_pid=""
redactor_pid=""
sampler_pid=""
proxy_pid=""
cleanup_playable_processes() {
local status=$? pid round alive
trap - EXIT
trap '' HUP INT TERM
for pid in "$child_pid" "$redactor_pid" "$sampler_pid" "$proxy_pid"; do
if [ -n "$pid" ]; then kill -TERM "$pid" 2>/dev/null || true; fi
done
for ((round=0; round<${process_cleanup_grace_seconds:-10}; round++)); do
alive=0
for pid in "$child_pid" "$redactor_pid" "$sampler_pid" "$proxy_pid"; do
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then alive=1; fi
done
[ "$alive" -eq 1 ] || break
sleep 1
done
for pid in "$child_pid" "$redactor_pid" "$sampler_pid" "$proxy_pid"; do
if [ -n "$pid" ]; then
kill -KILL "$pid" 2>/dev/null || true
wait "$pid" 2>/dev/null || true
fi
done
if [ -n "${fifo:-}" ] && [ -p "$fifo" ]; then rm -f "$fifo"; fi
return "$status"
}
trap cleanup_playable_processes EXIT
trap 'exit 129' HUP
trap 'exit 130' INT
trap 'exit 143' TERM