test(daemon): assert daemon exit with the predicate retirement confirms

Merged
TH
32m ago
+16-2

Summary

stopAndRetireDaemon confirms that the daemon exited through waitForDaemonExit, which counts a zombie as terminated (daemon-process.ts:85). A force-killed detached daemon is reparented to init and stays a zombie until init reaps it, and kill(pid, 0) still succeeds on a zombie. The test's isProcessAlive(pid) === false check, run right after a confirmed retired, therefore loses a race with init's reaping on some runners. This race failed "forced retirement waits for a real daemon…" on #4401 and #4396.

The production behavior is correct: a zombie holds no resources, and its pid cannot be reused until it is reaped.

Both exit assertions in smoke-daemon-clean.test.ts now check the recorded lifetime with waitForDaemonExit(..., { timeoutMs: 0 }), the same predicate retirement uses. The fix adds no sleep or retry, and a daemon that actually survived still fails the assertion. 1 file changed.

The race dates from #3806, not #4359. #4359 did not touch this stop path.

Validation

  • Tested SHA 0d1aee2.
  • Focused file: 10 of 10 runs pass. Unchanged base failed 5 of 5 runs, at lines 104 and 140, in a container whose init reaps about 1.5 s late.
  • pnpm check:quick and pnpm check:fallow --base origin/main pass.
  • pnpm check:affected --run --head 0d1aee2 passes, with exactCommit=true.
  • CI still owes the Integration Tests job.
  • Risk: low. The change is test-only.

Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.