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