From 8ee3bfbceff5ed922041b9e212e267acaa976857 Mon Sep 17 00:00:00 2001 From: claude-re Date: Thu, 30 Jul 2026 17:12:00 +0000 Subject: [PATCH] re-capture: stop detaching the display and the emulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ensure_display() and the run-canary launch used 'setsid nohup', to make them outlive the shell that started them. That is what has been killing every long run: a setsid'd process belongs to no supervised tree, and both Xvfb and xenia were reaped a couple of minutes in — the 'they die on their own every few minutes' note in the project memory. Measured: a bare Xvfb with no emulator running exited 0 (a clean shutdown, not a crash and not the OOM killer) at the exact moment a turn ended, and a session whose display was setsid'd from inside a tracked task died the same way 12 s after launch. Run launch_mission.sh as one tracked background task and keep Xvfb, openbox and xenia as its children. Adds an exit-status wrapper so a future death reports the server's own exit code (128+N for signal N) instead of being inferred, and clears a stale X lock before starting. --- tools/re-capture/launch_mission.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tools/re-capture/launch_mission.sh b/tools/re-capture/launch_mission.sh index 4126967..77cdadc 100755 --- a/tools/re-capture/launch_mission.sh +++ b/tools/re-capture/launch_mission.sh @@ -13,12 +13,25 @@ SD="$(cd "$(dirname "$0")" && pwd)" SHOTS=/sylph-home/re/shots alive(){ ps -o pid=,stat= -C xenia_canary 2>/dev/null | awk '$2 !~ /^Z/ {print $1}'; } + +# DO NOT `setsid` THE DISPLAY OR THE EMULATOR. They used to be detached into +# their own sessions so they would outlive the shell that started them. What +# that actually bought was the opposite: a process nothing owns is a process +# nothing keeps alive, and both were being reaped a couple of minutes in — the +# long-standing "Xvfb and the emulator die on their own every few minutes" note. +# Run this whole script as ONE tracked background task and leave Xvfb, openbox +# and xenia as its children: they then live exactly as long as the session does. +# `nohup` still shields them from a stray HUP; the exit-status wrapper means a +# death is reported with the server's own account instead of being inferred. ensure_display(){ if ! xdpyinfo -display "$DISPLAY" >/dev/null 2>&1; then - setsid nohup Xvfb "$DISPLAY" -screen 0 1280x720x24 -ac -nolisten tcp \ - +extension GLX +extension RANDR /tmp/xvfb98.log 2>&1 & + rm -f "/tmp/.X${DISPLAY#:}-lock" 2>/dev/null || true + nohup bash -c 'Xvfb "$0" -screen 0 1280x720x24 -ac -nolisten tcp \ + +extension GLX +extension RANDR >/tmp/xvfb98.log 2>&1 + echo "$(date +%T) XVFB EXIT $? (128+N means signal N)" >>/tmp/xvfb-exit.log' \ + "$DISPLAY" /dev/null 2>&1 & for _ in $(seq 1 50); do xdpyinfo -display "$DISPLAY" >/dev/null 2>&1 && break; sleep 0.2; done - setsid nohup env DISPLAY="$DISPLAY" HOME=/sylph-home openbox /tmp/openbox98.log 2>&1 & + nohup env DISPLAY="$DISPLAY" HOME=/sylph-home openbox /tmp/openbox98.log 2>&1 & sleep 1 fi xdpyinfo -display "$DISPLAY" >/dev/null 2>&1 || { echo "DISPLAY UNAVAILABLE"; exit 1; } @@ -32,7 +45,7 @@ rm -f /dev/shm/xenia_memory_* /dev/shm/xenia_code_cache_* 2>/dev/null ensure_display cd /sylph-home/re -setsid nohup run-canary --audio --apu=sdl --log_mask=13 \ +nohup run-canary --audio --apu=sdl --log_mask=13 \ --logged_profile_slot_0_xuid=E0300000EFBEA3D4 /dev/null 2>&1 & sleep 5 "$SD/skip_intro.sh" 600 || { echo "BOOT FAILED (skip_intro exit $?)"; exit 1; }