From 22d2518847ee0eda3b959b5ac09cfef9abb55610 Mon Sep 17 00:00:00 2001 From: "Claude (auto-RE)" Date: Wed, 29 Jul 2026 18:24:18 +0000 Subject: [PATCH] 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 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. --- tools/re-capture/grab_tutorial.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/re-capture/grab_tutorial.sh b/tools/re-capture/grab_tutorial.sh index c832370..6574c97 100755 --- a/tools/re-capture/grab_tutorial.sh +++ b/tools/re-capture/grab_tutorial.sh @@ -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 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