Repository navigation
fix(shell_exec): write small command input to a pipe, not a temp file - #4519
Merged
Merged
Conversation
Since #4400 (cd6732e), buffered_stdin put every command's input in an anonymous file from tempfile::tempfile(), including empty input. With an unusable TMPDIR, background hooks failed to spawn ("Failed to prepare detached input"), wt step for-each failed, wt list lost the working-tree diff of a worktree with untracked files (git add --pathspec-from-file=-), and background wt remove exited 1 after removing the worktree. v0.80.0 wrote input to a pipe and handled all of these. #4400 moved to a file so that no writer thread can block on a child that does not read its input. A pipe meets the same requirement when the whole input fits in its buffer: on Unix, buffered_stdin now writes the input into a fresh pipe through a nonblocking writer before spawn and closes the writer, so the child reads the bytes and then EOF. Only input larger than the pipe buffer (64 KiB on macOS and Linux) falls back to the anonymous file. Empty input is the empty-pipe case of the same path. Windows keeps the file. The list TMPDIR test now adds an untracked file and requires empty stderr, and a new remove test covers the detached cleanup with empty input; both fail without the fix. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Oct 20, 2026
…ilure A fresh pipe whose reader we hold fails a write only with WouldBlock, so the separate error arm was unreachable. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Oct 20, 2026
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.
Since v0.80.0, an unusable
TMPDIRbroke every command that passes input to a child: background hooks never spawned ("Failed to prepare detached input"),wt step for-eachfailed,wt listlost the working-tree diff of a worktree with untracked files (git add --pathspec-from-file=-failed), and backgroundwt removeexited 1 after already removing the worktree. #4400 moved this input from a pipe to an anonymous temp file, even when it was empty.The temp file exists so that no writer thread can block on a child that doesn't read its input. A pipe meets that requirement when the whole input fits in its buffer, so on Unix
buffered_stdinnow writes the input into a fresh pipe with a nonblocking writer before spawn and closes the writer. Only input larger than the pipe buffer (64 KiB on macOS and Linux) falls back to the temp file, and that case still needs a usableTMPDIR. Windows keeps the temp file.Verified with the release-review repros: with
TMPDIR=/nonexistent/dir, the post-start hook runs,for-eachsucceeds,wt listshows the dirty worktree, andwt removeexits 0, matching v0.80.0. The existing list TMPDIR test now adds an untracked file and requires empty stderr, and a new remove test covers the detached cleanup; both fail without the fix. The existingtest_cmd_with_stdincovers empty input and a 1.7 MB input that takes the temp-file path.