Skip to content

dvm: a worker that closes stdout can no longer be killed #1102

Open

Description

@chappie-daemon

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!:

loop {
    tokio::select! {
        line = lines.next_line() => {
            match line {
                Ok(Some(line)) => { ... }
                Ok(None) => break,      // stdout closed
                Err(_) => break,
            }
        }
        _ = &mut killed => {
            let _ = process.kill().await;
            break;
        }
    }
}

let (code, signal) = match process.wait().await { ... };

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.

Activity

  1. added
    bugSomething isn't working
    rewritenostream 4.0 Rust/LMDB rewrite
    rustRust implementation work
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrewritenostream 4.0 Rust/LMDB rewriterustRust implementation work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions