Repository navigation
fix(executor): keep prefix stdout when prefix stderr is relayed (Refs #3566) - #3860
Merged
Merged
Conversation
…3566) execute_external_prefix_concurrently assigned `input = prefix_output` only inside the no-stderr arm: when the last prefix member produced stderr without an ambient `exec 2>&1` merge, the else-if arm relayed stderr through the fd-table binding and the prefix's stdout payload was dropped before the shell-side tail ran. GNU execute_pipeline (execute_cmd.c:2620) gives each element an independent fd-1 pipe (pipe at :2646, do_piping in the forked child) while fd 2 stays the shell's own stderr — the streams are separate objects, so relaying stderr must not consume stdout. Assign `input = prefix_output` unconditionally after the stderr routing; the rubash#1552 ambient-merge and rubash#3308 fd-table relay are unchanged. (The commit also carries three rustfmt line-wrap normalizations the pre-commit hook requires on this file.) Pin: tests/issue3566_prefix_stdout_with_stderr.rs — primary cell red on the pre-fix tree (`pipeline rc=0` with the `g:g:two` payload missing), 3/3 green here; GNU bash 5.3.20 script probes match.
caomengxuan666
marked this pull request as ready for review
November 17, 2026 15:47
This was referenced Nov 17, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve pipeline_exec.rs against #3509 (member-own 2> redirects via configure_stage_stderr/stage_has_stderr_redirect) and #3860 (#3566 prefix stdout): wire() lays the ambient fd-table default first, then configure_stage_stderr applies the member's own redirect (the do_piping -> do_redirections order); Piped drains keep the child.stderr.take() guard; spawn-failure diagnostics ride write_default_stderr like the unix twin.
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.
Fixes #3566
Summary
execute_external_prefix_concurrently(Windows-only prefix-concurrent pipeline path) assignedinput = prefix_outputonly inside the no-stderr arm. When the last prefix member produced stderr without an ambientexec 2>&1merge, theelse ifarm relayed stderr through the fd-table binding (rubash#3308) and the prefix's stdout payload was dropped before the shell-side tail ran.GNU
execute_pipeline(execute_cmd.c:2620) gives every element an independent fd-1 pipe (pipe(fildes):2646,do_pipingin the forked child) while fd 2 stays the shell's own stderr — the streams are separate objects, so relaying stderr must not consume stdout.Fix:
input = prefix_outputunconditionally after the stderr routing. Theambient_stderr_merges_into_pipeline_output()merge (rubash#1552/#3403) and the fd-table stderr relay are unchanged. (Commit also carries 3 rustfmt line-wrap normalizations the pre-commit hook requires on this file.)Evidence
target/scratch-i3/rubash-3566.sh: base printederrmsg+pipeline rc=0(stdout gone); nowerrmsg+g:g:two+pipeline rc=0— byte-identical to GNU bash 5.3.20 (/usr/local/bin/bash,gnu-3566.sh).tests/issue3566_prefix_stdout_with_stderr.rs: 3/3 green; primary cell red on pre-fix tree (pipeline rc=0,g:g:twomissing).gnu-3566-extra.sh).Test plan
cargo build --locked --bin rubashcargo test --libdiff +-D warnings+ marker-lint (flagged for captain)