You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dvm: a worker that closes stdout can no longer be killed #1102
Found by the static review of the 026-nwc-req-before-event branch, run after its round 1: the finding is in a file that branch does not touch, and it is pre-existing on rewrite/main at 4adaa42.
The mechanism
crates/nostream-services/src/workers/dvm_orchestrator.rs:581-612 — drive_worker reads the child's stdout and watches the kill channel in one select!:
The killed arm is polled only inside the loop. Once stdout closes — a worker that finishes its output and then hangs, or one whose output is redirected — the function leaves the loop and blocks in process.wait(), where a later kill request has nothing polling its receiver. The sender in kill_worker completes, the child is never killed, and it survives until it exits on its own. Child is held right there, so the kill is still deliverable; nothing delivers it.
What a fix needs
Keep the killed arm active while waiting — a second select! over process.wait() and killed — or kill and reap the child when its output closes if that is the intended policy for a worker that ends its stream. Either way there needs to be a test with a child that closes stdout and then sleeps, asserting the kill reaches it; the current tests drive a child that exits, which is why this is invisible.
After stdout closes, the wait now runs in a select! with the kill request, so a timeout or shutdown kill still reaches the child and it's reaped (the capture's worker.kill() behaves the same)
New test: the child closes stdout, writes its pid and execs sleep 60; on rewrite/main it's still alive 5 s after the kill, with the fix it dies
All five CLAUDE.md checks pass (1818 tests); dvm_worker passed 100+ extra runs, including under load
Opened the PR on your behalf: #1258, from contrib/1102-kill-after-stdout, with your commit 53d92d07 cherry-picked -x so your authorship and the fork origin are kept.
Verification I ran before opening it, on a worktree based on rewrite/maina4312b69:
cargo test -p nostream-services --test dvm_worker — 12 passed
your new test alone, 10 consecutive runs — 10 passed
negative control: with only the dvm_orchestrator.rs hunk reverted and your test kept, it fails — the child is still alive 5 s after its kill request; restoring the hunk makes it pass, so the test does detect the defect
cargo test --workspace --all-features — exit 0, every binary ok, no failures
The select! shape is right: killed is a oneshot::Receiver created once at line 199 and polled only in drive_worker, so a completed receiver can only be observed by the arm that breaks the loop — the kill_requested guard keeps the plain wait from polling a spent receiver. No further changes were needed.
Landed on rewrite/main as 54a5a39f, squashed from #1258, and it carries your commit unchanged (7674833d) plus one test-only commit of mine (f2013247) that widened the test's job timeout from 500 ms to 3 s — the 500 ms was also the window in which the child had to spawn and write its pid, so a slow runner could fail the test with the fix in place.
Leaving this open, as with #1103: the fix is on rewrite/main, which the release PR does not track yet, so closing would claim a shipped fix. It closes when that line ships.
Closing as done. The fix is in drive_worker on rewrite/main (landed as 54a5a39, squashed from #1258): when stdout closes the loop still breaks, but the kill request stays live afterwards — the code now races process.wait() against the kill channel, so a child that closes its output and hangs is still killed, and the comment next to it names this issue.
main carries no crates/ tree, so there is nothing to port or follow up here: this code ships when rewrite/main becomes the release line, which is a release decision and not work left on this finding.
Activity
AgrimTawani commentedon Nov 23, 2026
Hey @cameri, is anyone working on this? If not, I'd like to give it a go.
killedarm live after stdout closes, with a secondselect!overprocess.wait()andkilledcameri commentedon Nov 24, 2026
@AgrimTawani Assigned to you
AgrimTawani commentedon Nov 25, 2026
Hey @cameri, the fix is ready on my fork; I can't open the PR myself: rewrite/main...AgrimTawani:nostream:fix/1102-kill-after-stdout-closes
select!with the kill request, so a timeout or shutdown kill still reaches the child and it's reaped (the capture'sworker.kill()behaves the same)execssleep 60; onrewrite/mainit's still alive 5 s after the kill, with the fix it diesCLAUDE.mdchecks pass (1818 tests);dvm_workerpassed 100+ extra runs, including under loadagrim-sarvam commentedon Nov 26, 2026
Hey @cameri, just a nudge on this one. The fix is still ready on my fork, whenever you have time to open the PR: rewrite/main...AgrimTawani:nostream:fix/1102-kill-after-stdout-closes
rewrite/maindcf0259; all fiveCLAUDE.mdchecks pass, and I can rebase it if you needchappie-daemon commentedon Nov 27, 2026
Opened the PR on your behalf: #1258, from
contrib/1102-kill-after-stdout, with your commit53d92d07cherry-picked-xso your authorship and the fork origin are kept.Verification I ran before opening it, on a worktree based on
rewrite/maina4312b69:cargo fmt --all --check— cleancargo clippy --workspace --all-targets --all-features -- -D warnings— cleancargo test -p nostream-services --test dvm_worker— 12 passeddvm_orchestrator.rshunk reverted and your test kept, it fails — the child is still alive 5 s after its kill request; restoring the hunk makes it pass, so the test does detect the defectcargo test --workspace --all-features— exit 0, every binary ok, no failuresThe
select!shape is right:killedis aoneshot::Receivercreated once at line 199 and polled only indrive_worker, so a completed receiver can only be observed by the arm that breaks the loop — thekill_requestedguard keeps the plain wait from polling a spent receiver. No further changes were needed.chappie-daemon commentedon Nov 27, 2026
Landed on
rewrite/mainas54a5a39f, squashed from #1258, and it carries your commit unchanged (7674833d) plus one test-only commit of mine (f2013247) that widened the test's job timeout from 500 ms to 3 s — the 500 ms was also the window in which the child had to spawn and write its pid, so a slow runner could fail the test with the fix in place.Leaving this open, as with #1103: the fix is on
rewrite/main, which the release PR does not track yet, so closing would claim a shipped fix. It closes when that line ships.chappie-daemon commentedon Nov 27, 2026
Closing as done. The fix is in
drive_workeronrewrite/main(landed as 54a5a39, squashed from #1258): when stdout closes the loop still breaks, but the kill request stays live afterwards — the code now racesprocess.wait()against the kill channel, so a child that closes its output and hangs is still killed, and the comment next to it names this issue.maincarries nocrates/tree, so there is nothing to port or follow up here: this code ships whenrewrite/mainbecomes the release line, which is a release decision and not work left on this finding.