Repository navigation
fix(function): preserve call-site file stdin across child spawn - #653
Merged
Merged
Conversation
GNU execute_cmd.c execute_function applies the call redirect around the body and redir.c do_redirections inherits the open file description and shared offset. Keep ordinary function call-site files in FdTable instead of slurping them into FUNCTION_STDIN.
caomengxuan666
added a commit
that referenced
this pull request
Oct 16, 2026
PR #653 flipped precedence: f() { cat; } < deffile; f < callfile printed call; GNU prints definition (call-site outer, definition inner per execute_cmd.c:5205). The (None, _, binding) arm installed the live fd 0 then fell through to the call-site file, overwriting it. Keep a live definition fd-0 binding; skip call-site stdin then. part_054 14/14.
caomengxuan666
added a commit
that referenced
this pull request
Oct 16, 2026
PR #653 flipped precedence: f() { cat; } < deffile; f < callfile printed call; GNU prints definition (call-site outer, definition inner per execute_cmd.c:5205). The (None, _, binding) arm installed the live fd 0 then fell through to the call-site file, overwriting it. Keep a live definition fd-0 binding; skip call-site stdin then. part_054 14/14. Co-authored-by: caomengxuan666 <[email protected]>
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.
Summary
Fixes #647. Ordinary file redirects at a function call site now stay on the real fd-table file descriptor instead of being slurped into the FUNCTION_STDIN text mirror. External children inherit the open file description and shared file offset, so later shell reads continue from the correct line.
Validation
References