re: don't let zombie emulators fool the liveness check

Container PID 1 is `sleep infinity` and never reaps, so every emulator this
script kills stays as a <defunct> entry that `pgrep -x` still matches -- after
a few captures the script always believed one was running. Same trap as the
Xvfb check. Ask ps for the process state and skip anything in Z.
This commit is contained in:
2026-07-29 18:24:18 +00:00
parent 1ee2d5e406
commit 22d2518847

View File

@@ -31,8 +31,12 @@ ensure_display(){
step(){ vgamepad dpad "$1"; sleep 0.2; vgamepad dpad center; sleep 0.6; }
shot(){ screenshot "$SD/$1" >/dev/null 2>&1; }
# Container PID 1 is `sleep infinity`, which never reaps, so every killed
# emulator stays as a <defunct> entry that `pgrep` still matches. Ask ps for the
# state and ignore anything zombie, or this always thinks one is running.
alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; }
pkill -x xenia_canary 2>/dev/null; sleep 2
pgrep -x xenia_canary >/dev/null && { pkill -9 -x xenia_canary; sleep 2; }
[ -n "$(alive)" ] && { kill -9 $(alive) 2>/dev/null; sleep 2; }
rm -f /dev/shm/xenia_memory_* /dev/shm/xenia_code_cache_* 2>/dev/null
ensure_display