Repository navigation
WIP: /dev/fd alias-output faces — external stdio plan + numbered/stage delivery (#2285, #2295) - #2297
Merged
Merged
Conversation
…argets Refs #2285 `exec 6<seed; /bin/echo X > /dev/fd/6` wrote X to the shell's real stdout and left seed untouched: the stdio plan classified the alias PATH spelling as a dup source, found no write endpoint on the read-bound binding, and declined; the legacy stdio arms then fired on no branch (not closed, not a stdio dup, no output endpoint, and the plain-open arm requires a non-fd target). GNU spec: with HAVE_DEV_FD defined, redir.c's RF_DEVFD dup special case (redir.c:602-629) does not compile, so an alias spelling under an output instruction takes the plain open in redir_open (redir.c:725, via do_redirections at redir.c:237) — a FRESH open of the resolved regular file, truncate/append per the instruction, noclobber-refused under set -C, regardless of the source endpoint's direction or offset. Oracle-verified against GNU bash 5.3.20, including the read-write and write-bound source shapes (fresh + truncate in both; the issue text's shared-offset control claim for `6<>file` is falsified — the `>&N` dup spelling is the shared-offset one and is unchanged). Fix: one shared resolver in the alias layer (Executor::open_alias_spelling_fresh_output + open_fresh_alias_file, the File-returning twin of the buffered face's write_fresh_alias_file_output from #2275), consulted by the stdio plan's Output/Append/ClobberOutput arm (fds 1/2) and by the four legacy stdio arms (stdout/stderr x truncate/append), placed after the stdio-dup arms so the piped-fallback routing is not preempted. Dup spellings (`>&N`, `>&-`) never reach the resolver. Pins: tests/issue2285_external_alias_output_regressions.rs — the reproducer, append (contents preserved), read-write and write-bound fresh controls, noclobber refusal with target untouched, the fd-2 form, and a `>&6` dup-spelling shared-offset control. GNU expectations from probes/oracle-pins.sh (cluster workdir).
…ut targets Refs #2295 `exec 6<seed.txt; sh -c 'echo o >&3' 3>/dev/fd/6 | wc -c` counted 0 for the wrong reason and left seed.txt empty: the parent-side routing probe fresh-opened (truncated) the target, and the spawn delivery walk then SKIPPED the entry (its generic alias arm), so the stage child got EBADF at fd 3 and wrote nothing. GNU counts 0 because the byte lands in seed.txt (`o\n`). GNU spec: the alias PATH spelling is an open over the alias layer (redir.c:725 redir_open via do_redirections, redir.c:237; the RF_DEVFD dup special case at redir.c:602-629 compiles only without HAVE_DEV_FD) — for a regular-file endpoint a FRESH open, the same doctrine the stdio faces implement in the #2285 commit of this PR. Fix: one arm in apply_external_fd_delivery's numbered walk, ahead of the generic alias skip — Output/Append/ClobberOutput entries with an alias PATH spelling (never a `>&N` dup spelling) resolve through fd_alias_reopen_path and fresh-open via the shared open_fresh_alias_file, delivered through the walk's existing stamp/pin channels (stamp_child_fd_handle) and recorded in walk_opened so a later same-list dup chains onto this description. The walk is shared by the pipeline stage spawner and spawn_external_process, so one arm serves the stage face and the simple-command numbered face. The parent probe's truncation is observably harmless once delivery works (the child's own fresh open re-truncates for `>`; append probes open in append mode; noclobber is enforced by the probe pre-run) — the #1868-style probe architecture is deliberately not redesigned here. Resolver misses (non-regular endpoints) and ReadWrite entries keep their existing paths. Pins: tests/issue2295_stage_alias_output_regressions.rs — the stage reproducer (count 0 + target holds `o\n`, NOT truncated-empty), stage append (contents preserved), a mid-stage variant, the simple-command numbered truncate/append shapes, and an input-direction control. GNU expectations from probes/oracle-pins.sh (cluster workdir).
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.
Cluster PR for the last two faces of the /dev/fd alias-output family. Refs-only; the collector closes the issues after batch verification under scrubbed fds.
Commits
1b0996e0) — external stdio faces (plan + four legacy arms) fresh-open alias output targets via one shared resolver in the alias layer (open_alias_spelling_fresh_output/open_fresh_alias_filein shell_options.rs, the File-returning twin of WIP: /dev/fd/N alias open of a regular file re-opens fresh (#2256) #2275's buffered helper).4d075d81) — the numbered spawn delivery walk (apply_external_fd_delivery, shared by the pipeline stage spawner andspawn_external_process) gains the matching output arm, so one walk fix serves stage and simple-command numbered shapes.The two issues share ONE mechanism (an alias PATH spelling under an output instruction is a fresh open of the resolved regular file); they diverge only in which consumer lacked the resolver arm — hence one shared helper, two consumer commits.
⚠ Oracle correction to #2285's issue text
The issue's control claim —
exec 6<>seedkeeps "dup shared-offset semantics" for> /dev/fd/6— is falsified by the GNU 5.3.20 oracle: the alias PATH spelling fresh-opens (truncate) for read-bound, read-write, AND write-bound sources alike. The shared-offset form is the>&Ndup spelling, which is unchanged. Pins assert the oracle; probe script: cluster workdirprobes/oracle-pins.sh.GNU spec
redir.c:237
do_redirections; redir.c:725redir_open(the plain open every output word takes); redir.c:602-629 RF_DEVFD dup special case compiles only#if !defined (HAVE_DEV_FD)— the oracle build defines it.Verification status
Compile rationing:
cargo check+cargo check --testfor both new pin targets, clean; per-file rustfmt on touched files only; LF = 0. NO local test runs — pins are for the collector's scrubbed-fd batch:issue2285_external_alias_output_regressions(7 pins)issue2295_stage_alias_output_regressions(6 pins)Open adjudication point for the batch: whether the concurrent pipeline path (not the sequential stage spawner) serves the #2295 stage shape without declining — the stage pins will show it. Full census of alias-layer consumers, discoveries, and the run/pending split are in the cluster REPORT.md.