[Bug] Daemon can never start again after its supervisor is left unreaped as a zombie #1732
mdumitrean
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Agent core
What happened?
A daemon supervisor whose parent never reaps it — the parent CLI suspended with Ctrl+Z, or otherwise stopped — lingers as a zombie. A zombie still answers kill(pid, 0), and ps still reports its original start time, so both checks the supervisor ownership registry makes on the recorded owner pass: it reads the dead generation as the live owner and rejects every subsequent launch.
Error: Prime Agent daemon exited during startup (code 1).
DaemonSupervisorAlreadyRunningError: Daemon supervisor already owns
$TMPDIR/prime-agent-/daemon.sock
The state is permanent, not transient: the socket is long gone, so no client can connect either, and nothing ever clears the registry record. utils/child-process.ts already exported an isProcessAlive that excludes zombies, but six modules had each re-implemented a bare kill(pid, 0) probe and none of them used it.
Steps to reproduce
Deterministic:
npx vitest --run test/daemon-supervisor-ownership.test.ts
-t "reclaims an owner whose process is an unreaped zombie"
It parks a real unreaped child in an owner record and asserts acquisition reclaims it.
Manual:
The probe behavior that makes it stick, checkable directly against that pid:
kill -0 # succeeds
ps -p -o lstart= # still prints the original start time
Expected behavior
Prime Agent version
9e49b73
Environment
macOS 26
Additional context
No response
All reactions