Red on ubuntu CI under -race at 5bfd76cd8 (run of the Test workflow):
"the run answering, pid 42298, is listed as {PID:0 ...}". The wait took
a listing first and read hang.pid after it. A listing made while the
second run's launch had started Claude Code but not yet set its tree
(983fff23d reads the pid only once the tree is set) has that run at
PID 0; by the time the condition read hang.pid the fake had written
it, so the wait ended on a list without the hung pid. The condition
now also needs a run listed with that pid, which is the state the
check after it is about.
Run on mote (macOS 27), at this tree:
- Injected a 500ms sleep in claudeRuns for a run listed at PID 0 (and
300ms in launch before the tree is set): the old test is red 3 of 3
with CI's exact message, this one is ok -count=3.
- Without injection: go test -race -tags nogui -count=5 -run
TestClaudeRuns ./internal/gateway: ok. gofmt -l clean.
Not changed: the listing itself; a run whose launch hasn't set its tree
yet is listed at PID 0, as before.