Skip to content

fix: close pipe fds in parent to prevent deadlock when child exits#228

Merged
alecthomas merged 1 commit intomainfrom
aat/fix-pipe-deadlock
Mar 26, 2026
Merged

fix: close pipe fds in parent to prevent deadlock when child exits#228
alecthomas merged 1 commit intomainfrom
aat/fix-pipe-deadlock

Conversation

@alecthomas
Copy link
Copy Markdown
Collaborator

StdoutPipe() retains the pipe read end in the parent until Wait() runs
closeAfterWait. If the downstream process exits early, the upstream
cannot receive SIGPIPE (parent still holds the read end), so it blocks
on pipe write and Wait() deadlocks.

Replace StdoutPipe() with manual os.Pipe() in Create, StreamTo, and
Extract, closing both ends in the parent immediately after starting
child processes.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

StdoutPipe() retains the pipe read end in the parent until Wait() runs
closeAfterWait. If the downstream process exits early, the upstream
cannot receive SIGPIPE (parent still holds the read end), so it blocks
on pipe write and Wait() deadlocks.

Replace StdoutPipe() with manual os.Pipe() in Create, StreamTo, and
Extract, closing both ends in the parent immediately after starting
child processes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alecthomas alecthomas requested a review from a team as a code owner March 26, 2026 23:28
@alecthomas alecthomas requested review from joshfriend and removed request for a team March 26, 2026 23:28
@alecthomas alecthomas enabled auto-merge (squash) March 26, 2026 23:28
@alecthomas alecthomas merged commit 14e792d into main Mar 26, 2026
6 checks passed
@alecthomas alecthomas deleted the aat/fix-pipe-deadlock branch March 26, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant