Repository navigation
WIP: executor: deliver numbered stdio dups on the simple-command spawn face - #2290
Merged
Merged
Conversation
Refs #2278 The numbered redirect walk in apply_external_fd_delivery skipped dup spellings outright, so `cmd 3<&0 <seed` and `cmd <seed 3<&0` both left the child's fd 3 unbound (EBADF). GNU services every dup in its single ordered walk with a dup2 of the source as bound at that walk position (redir.c:237 do_redirections; redir.c:1138 do_redirection_internal, dup2 at :1193). Add deliver_numbered_dup, mirroring the #2277 {var} ladder by mechanism: (1) a binding this walk already delivered for the source, (2) the #2235 fd-0 replay for the command's own stdin binding, (3) the ambient fd table's endpoint at the source (a File endpoint stamps/pins; a text snapshot rides a carrier through the generalized deliver_fd_var_text_binding), (4) a stdio source — a child-local pin when no later entry rebinds the source slot, or a parent-side capture of the ambient stdio descriptor when one does (`3<&0 <seed` delivers the ambient stdin, not the seed the later entry wires into the child's fd 0). Bindings that are not FileFds are recorded per slot so a later dup in the same list chains onto the same binding. Move spellings (`4<&3-`) keep their existing fall-through. Regression pins in tests/issue2278_numbered_stdio_dup_regressions.rs (both dup orders, the output order pair, chains, controls), expectations byte-verified against GNU bash 5.3.20 probe cells. Pins are not run locally under the compile-rationing regime; the collector batch-verifies them under a scrubbed fd environment.
caomengxuan666
marked this pull request as ready for review
October 30, 2026 23:24
This was referenced Oct 30, 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.
Refs #2278
Problem
On the simple-command spawn face, numbered stdio dups were never
delivered: the numbered redirect walk in
apply_external_fd_deliveryskipped dup spellings outright, socmd 3<&0 <seedandcmd <seed 3<&0both left the externalchild's fd 3 unbound (EBADF). GNU bash 5.3.20 delivers both
orders — the dup copies the source as bound at its position in
the one ordered redirect walk (redir.c:237
do_redirections;redir.c:1138
do_redirection_internal, thedup2at :1193).Fix
One mechanism, mirroring the ladder PR #2277 landed for the
{var}channel (deliver_fd_var_dup), adapted to the numberedwalk which has no dynamic-fd applier — new
deliver_numbered_dupinsrc/executor/external_inner.rs:(
walk_opened) stamps/pins at the target — covers3<seed 4<&3chains.the 列表级输入 procsub 3< <(...) 未物化(#2196 输入侧兄弟面) #2235 replay (
own_input_binding_before) — covers<seed 3<&0.endpoint stamps/pins directly (covers
exec 3<seed+cmd 4<&3); a text snapshot rides a carrier throughdeliver_fd_var_text_binding, generalized to take separatesnapshot/deliver slots (its three
{var}call sites pass thesame slot twice, unchanged behavior).
slot, the child's wired slot IS the at-position binding, so a
child-local pin (the WIP: {fd} variable-form redirects — spawn delivery for all kinds #2277 step-5 shape) is exact. If a later
entry DOES rebind it (
3<&0 <seed,3>&1 >sink), theat-position binding is the ambient one, so the shell's
ambient stdio descriptor is captured parent-side
(inheritable dup) and pinned instead — the wired slot will
hold the later binding and must not be read.
Bindings that are not FileFds are recorded per slot
(
NumberedDupBinding) so a later dup in the same list chainsonto the same binding (
3<&0 4<&3 <seeddelivers the ambientstream at fd 4). Move spellings (
4<&3-) are not intercepted —they keep their existing fall-through. An unresolvable source
delivers nothing; closed sources are diagnosed on the redirect
preflight face, as in the
{var}ladder.Tests
New target
tests/issue2278_numbered_stdio_dup_regressions.rs(13 pins): both dup orders with a foreign
ddobserver reading/dev/fd/3, the issue's nested-rubash seed shapes in bothorders, plain stdio dup, numbered chain, ambient numbered
source, chain through a stdio dup, the output order pair
(
3>&1 >sink→ ambient stdout;>sink 3>&1→ the file), plustwo controls (numbered file binding; the #2277
{var}stdiodup through the shared walk). Expectations were byte-verified
against the GNU bash 5.3.20 oracle with the probe cells kept in
the cluster workdir (
probes/cells, oracle table inprobes/README.md).Per the compile-rationing regime the pins were not run
locally (only
cargo check+cargo check --test issue2278_numbered_stdio_dup_regressions, both clean); thecollector batch-verifies them under a scrubbed fd environment,
together with the control targets
issue2272(24 pins),issue2235,issue2255,issue2256, andissue2270.