Repository navigation
WIP: fix #2599 producer {var} dup pin precedence - #2604
Merged
Merged
Conversation
caomengxuan666
force-pushed
the
fix/2599-producer-varfd
branch
from
November 2, 2026 10:58
92201ae to
f7decf9
Compare
… (Refs #2599) Inside a respawned shell (procsub producer, plain -c child, background respawn) an external command whose redirect list rebinds fd N with a plain entry and then dups it via {var}>&N received the producer's AMBIENT fd-N description at the var's slot instead of the same-list rebind: writes landed in the outer shell's fd-N file and the plain target stayed empty, silently. GNU law: redir.c:237 do_redirections is one ordered walk over one descriptor space in the forked child; the REDIR_VARASSIGN F_DUPFD copy (redir.c:940 area) resolves its source at its list position. subst.c:6362 process_substitute's producer is a fork, so its in-body commands observe the same walk. Rubash's delivery walk already resolved the dup at position (deliver_fd_var_dup step 1, walk_opened), but pin_ambient_fds_in_child broke the merged pin list's precedence (ambient first, command pins appended, later dup2 wins — rubash#1686): in a respawned shell's sparse fd space the walk opens the plain target at the OS fd equal to the {var} slot, making the command pin source==target, and the pin pass "applied" it at staging time by merely clearing CLOEXEC. The ambient pin for the same slot (the applier's copy of ambient fd N) then dup2'd over it in phase two. Remove the shortcut: every pin stages above the ceiling and dup2's in list order, so a source==target pin occupies its own precedence position. Pins: the two #2522 wave-3 residuals moved verbatim from PR #2569 plus the producer-internal exec-rebind shape.
caomengxuan666
force-pushed
the
fix/2599-producer-varfd
branch
from
November 2, 2026 11:17
f7decf9 to
1814bb6
Compare
caomengxuan666
marked this pull request as ready for review
November 2, 2026 11:19
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.
Refs #2599