Repository navigation
test(process): count zombie descendants as stopped in cleanup checks - #12091
Conversation
Where PID 1 does not reap orphans promptly, a killed descendant stays a zombie for a while. Signal 0 still reaches a zombie, and a raw process table still lists it, so four boundary tests decided a stopped process was alive although cleanup had worked. The stop assertions in artifactVerifierCleanupOwner and desktopBuildOwnedCommand now use processHasStopped. The run-token sweep in ownedCommand reads the product's liveProcesses view, which drops zombie rows. The testing guide says to assert a stop this way and not with signal 0. Ported onto current main from morluto#11837. The helper and the first eight cases landed in morluto#12034, so this keeps the four that remained.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Low impact] This PR appears safe to merge; no actionable issues were found. SummaryThis test-only change counts exited zombie descendants as stopped, avoiding false cleanup failures in containers that do not promptly reap orphaned processes.
No actionable issues found. Running children still fail the checks, and inspection errors are not swallowed. No new security issue was identified. Tests were not run during this review. Davmunrey explicitly left other signal-0 assertions unchanged because they mostly check direct children that their parents reap. The checked Reviews (1) · Last reviewed commit: "test(process): count zombie descendants ..." · Reviewed by Greptile |
#14) Adds morluto/rea#12089 and morluto/rea#12091 to the REA list and updates the in-review line.
Summary
After #12034, three boundary tests still fail where PID 1 does not reap orphans promptly (a container started without an init process). They decide that a killed descendant is alive with signal 0, which still reaches a zombie.
This is the part of #11837 by @djrk935 that #12034 did not land, ported onto current
main, where #11837 now conflicts. The commit keeps the original author. If #11837 is updated instead, close this one.Refs #11819, which #12034 closed. That issue listed eight tests; these are the further cases #11837 found.
Problem and expected behavior
Smallest trigger: run these tests on Linux where PID 1 leaves an orphaned, killed process as a zombie for a few seconds.
artifactVerifierCleanupOwner› joins an owned protocol process and its descendant before closingdesktopBuildOwnedCommand› stops the packing process family before removing its partial archive on timeoutdesktopBuildOwnedCommand› cancels a running setup process family before removing its partial outputEach asserts
process.kill(pid, 0)throws after cleanup. Reading/proc/<pid>/stataroundtransport.close()in the first test shows what happens: the direct child is gone (ESRCH), the descendant is in stateZwith PPID 1 and still answers signal 0, and it disappears within about 3 seconds. Cleanup worked; the assertion read a dead process as alive.Expected: a process that has exited and only waits to be reaped counts as stopped, as
tests/support/process/observePosixProcess.tsalready defines it.Change and scope
artifactVerifierCleanupOwneranddesktopBuildOwnedCommand: the three stop assertions useprocessHasStopped, the helper fix(tests): treat zombies as stopped in process liveness checks (#11819) #12034 added.ownedCommand: the run-token sweep reads the product'sliveProcessesview of the process table, which drops zombie rows, instead of the raw table.docs/development/testing.md: one paragraph says to assert a stop withprocessHasStoppedorprocessGroupHasStopped, not signal 0.Test-only. No production code changes.
Differences from #11837: everything #12034 already landed is dropped (the helper,
mcpDoctor,desktopTaskReaderRunner, the Kuna probe launcher and their tests). The three assertions useprocessHasStoppedinstead ofobservePosixProcess(...).kind, and the guide names the two helpers that exist onmain, becauseobservePosixProcessGroupdid not land.Not included: the other signal-0 assertions in the suite. They pass in this environment, mostly because they check a direct child that its parent reaps.
Contract and boundary impact
tests/boundary/process/assertions;tests/support/process/observePosixProcess.tsis used unchanged.processHasStoppedkeeps signal 0 there.docs/public/product-catalog.json), package, or installation impact: none;npm run docs:checkpassed.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
ownedCommandsweep listed above. No new test.process_api, running as root, Linux x64, Node 24):main(b236bcfe3) the three test files give 3 failed, 32 passed. The same three tests failed in the full built group on23adfc610and when run alone on an idle machine.b236bcfe3: 35 passed, in three consecutive runs./procobservation described above: stateZ, PPID 1, gone within about 3 seconds.ownedCommandcase passed onmainhere too, because this PID 1 reaps inside that test's 2 second poll, so I could not reproduce that one; the change is kept as test(process): count zombie descendants as stopped in cleanup checks #11837 wrote it. Not run on a host with a reaping init; CI covers that.Lifecycle regressions: these are the owned-process cleanup scenarios (protocol transport close, setup timeout, setup cancellation). The assertions still fail if a member of the process family keeps running.
For evidence-bearing changes:
Validation performed
On
b236bcfe3plus this change, in the environment above.npx vitest run tests/boundary/process/artifactVerifierCleanupOwner.test.ts tests/boundary/process/desktopBuildOwnedCommand.test.ts tests/boundary/process/ownedCommand.test.ts— 35 passed, three runs; 3 failed withmain's versions of the filesnode scripts/run-typescript.mjs --noEmit— no errorsnpm run check:fast— passednode scripts/verify/architecture-guards.mjs— passed across 2873 source filesnpm run docs:check— passednpx oxfmt --check docs/development/testing.md tests/boundary/process— all formattedCompatibility, safety, and release
psand send no signal.Author readiness
Human owner: @Davmunrey
Before merge
type(scope): outcome.