Files
BT411/scratchpad/btwait_probe.ps1
T
arcattackandClaude Opus 5 7afbda900e the terminal that never closes: every launcher waited for ANY btl4.exe on the machine
Operator report: "X-closing the game leaves the terminal open and leaves
orphaned processes."  Investigated on the rig against 4.11.600.

The terminal half is real and is THIS: :btwait polled
`tasklist /FI "IMAGENAME eq btl4.exe"`, which is machine-wide, so a bat that
launched nothing at all keeps spinning while an unrelated instance lives --
proved with btwait_probe.ps1.  A second client, the operator's own pod, or an
orphan from a crash therefore hangs every join window, which reads as "the game
never exited" and invites people to start killing processes.  All four
launchers carried the identical block.

Fix: snapshot the btl4 PIDs alive BEFORE the launch; wait only on PIDs absent
from that snapshot.  The `if /I "%%P"=="btl4.exe"` guard is deliberately kept --
tokens=2 alone parses tasklist's "INFO: No tasks are running" line as a PID and
spins forever with nothing running, which would be worse than the bug.

Verified with the text lifted verbatim from the shipped play_solo.bat: nothing
running -> signs off (the regression guard); someone else's instance -> signs
off; our own generation -> keeps waiting; decoy gone -> signs off.  The patched
bat still launches (pid + launch_report.txt).  NOT verified: the full handoff
E2E, because the bat blocks on the FE menu waiting for a human.

The orphan half did NOT reproduce on 600: closing the MAIN window exits cleanly
in ~1s during solo model-load, in the relay join wait, and after a real console
launch, with the relay logging the seat freed.  The orphans the playtesters saw
match 584 and earlier, where every close relaunched.  Full write-up, including
the aux windows that hide instead of closing and the WM_QUIT that BTLoadPump
swallows, in phases/phase-12-orphan-processes.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 16:06:39 -05:00

34 lines
1.6 KiB
PowerShell

# Does join.bat's :btwait loop wait for ANY btl4.exe, or only its own?
# Run the EXACT fragment from join.bat while an unrelated btl4 is alive.
$content = 'C:\git\bt411\content'
$scratch = 'C:\Users\epilectrik\AppData\Local\Temp\claude\C--git-bt411\89ab96e9-6cf0-4555-939d-05bf3708745a\scratchpad'
# an UNRELATED instance -- stands in for the operator's own pod, a second
# client, or a genuine orphan. Nothing to do with the bat we are testing.
$env:BT_LOG='btwait_other.log'; $env:BT_START_INSIDE='1'
foreach ($v in 'BT_RELAY','BT_FE_LOOP','BT_SELF') { Remove-Item -LiteralPath "Env:\$v" -ErrorAction SilentlyContinue }
$other = Start-Process 'C:\git\bt411\build\Release\btl4.exe' -ArgumentList '-egg','ARENA1.EGG' `
-WorkingDirectory $content -PassThru
"unrelated btl4 running as pid $($other.Id)"
Start-Sleep -Seconds 6
# the exact loop body from join.bat lines 55-63, minus the goto
$frag = @'
@echo off
set "BT_STILL_RUNNING="
for /f "tokens=1" %%P in ('%SystemRoot%\System32\tasklist.exe /FI "IMAGENAME eq btl4.exe" /NH 2^>nul') do (
if /I "%%P"=="btl4.exe" set "BT_STILL_RUNNING=1"
)
if defined BT_STILL_RUNNING (echo BTWAIT: would KEEP SPINNING -- terminal stays open) else (echo BTWAIT: would exit and print "The game has exited")
'@
$fragPath = Join-Path $scratch 'btwait_frag.bat'
Set-Content $fragPath $frag -Encoding Ascii
'--- the bat that launched NOTHING now runs the wait loop ---'
& cmd.exe /c $fragPath
Stop-Process -Id $other.Id -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
'--- same loop with no btl4 anywhere ---'
& cmd.exe /c $fragPath