fix(shell): bound post-exit pipe draining on all platforms - #46085
Merged
Merged
Conversation
|
1 |
Hona
marked this pull request as ready for review
August 31, 2026 05:00
|
the problem still exists on 1.18.27 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
A command can exit while a background child still has its output pipes open. We keep waiting for EOF, so the shell tool never finishes.
Related issue reports
This fixes the V2 implementation of the post-exit hangs reported below.
Start-Processwith-RedirectStandardOutput/-RedirectStandardErroron Windows #37838Earlier reports, already closed: #19252, #22012, #22154, #24731, #24784, #24926, #25938, #29294, #29822, #33363.
Previous fix attempts: #20901, #28336, #29831, #42756, #43511, #44601.
Type of change
What does this PR do?
Give stdout and stderr one shared second to drain after the parent exits. Then finish capture and let the shell return instead of waiting on the background child.
The important part is keeping that separate from process cleanup. Shell timeouts still escalate to SIGKILL, and closing an MCP server still cleans up its descendants. No public API changes.
The tradeoff is that we can lose trailing output. Later bytes are discarded, and writers can get
EPIPE/SIGPIPEonce their readers close.How did you verify your code works?
Added four real-process regression cases: held pipes after exit, SIGKILL completion, MCP descendant cleanup, and shell timeout escalation. Each test also fails when its corresponding fix is disabled.
Validation and remaining limits
echoquoting failure; Unix-only cases are skipped.taskkillattempt, taking roughly 0.35-0.73 seconds in our checks.Checklist