Skip to content

WIP: fix #2599 producer {var} dup pin precedence - #2604

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2599-producer-varfd
Nov 2, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2599-producer-varfd

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #2599

… (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.
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