Repository navigation
fix(minimal): stop task run hanging on a held-open stdin pipe - #1741
norrietaylor merged 3 commits into
Conversation
`min task run` pumped piped stdin through `tokio::io::stdin()`, a blocking `read(0)` parked on tokio's blocking pool. `pump.abort()` cannot interrupt that read, so when stdin was a pipe whose writer stayed open, the runtime drop waited on the blocking thread forever after the task's exit status had already arrived. Read stdin on a detached `std::thread` instead, feeding an mpsc channel that the async pump drains into the exec channel. The thread is abandoned on exit rather than awaited, so a held-open pipe can no longer keep the process alive. Add a regression test that runs the compiled binary with the stdin write end held open and asserts it exits within a timeout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowanc 8000 e at 2 reviews per hour. 📝 WalkthroughWalkthroughThe exec bridge forwards piped stdin through a detached reader thread and a bounded Tokio channel. A Linux-only CLI test checks task output while the subprocess stdin pipe remains open. ChangesPiped stdin forwarding
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant StandardInput
participant ReaderThread
participant BoundedTokioChannel
participant AsyncPump
participant SSHExecChannel
StandardInput->>ReaderThread: Provide stdin bytes
ReaderThread->>BoundedTokioChannel: Send chunks
BoundedTokioChannel->>AsyncPump: Deliver chunks
AsyncPump->>SSHExecChannel: Write chunks
AsyncPump->>SSHExecChannel: Shut down writer when forwarding ends
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change stops 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit reads the piped-in stream, Comment |
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABTSyWRA
Problem
min task runhangs at exit when its stdin is a pipe whose writer staysopen.
bridge_execpumped piped stdin throughtokio::io::stdin(), ablocking
read(0)parked on tokio's blocking pool.pump.abort()cannotinterrupt that read, so once the task's exit status arrived the runtime
drop waited on the blocking thread forever.
Change
Read stdin on a detached
std::threadinstead, feeding atokio::sync::mpscchannel that the async pump drains into the execchannel. The thread is abandoned on exit rather than awaited, so a
held-open pipe can no longer keep the process alive.
Verification
cargo fmt --all -- --checkcargo clippy -p minimal --all-targets --no-deps --locked -- -D warningscargo build --workspace --lockedcargo test -p minimal --locked --test cli(38 passed, incl. new regression test)Summary by CodeRabbit