Skip to content

fix(executor): keep prefix stdout when prefix stderr is relayed (Refs #3566) - #3860

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3566-prefix-stdout
Nov 17, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3566-prefix-stdout

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #3566

Summary

execute_external_prefix_concurrently (Windows-only prefix-concurrent pipeline path) 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 (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_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.

Fix: input = prefix_output unconditionally after the stderr routing. The ambient_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

  • Repro target/scratch-i3/rubash-3566.sh: base printed errmsg + pipeline rc=0 (stdout gone); now errmsg + g:g:two + pipeline rc=0 — byte-identical to GNU bash 5.3.20 (/usr/local/bin/bash, gnu-3566.sh).
  • Pin tests/issue3566_prefix_stdout_with_stderr.rs: 3/3 green; primary cell red on pre-fix tree (pipeline rc=0, g:g:two missing).
  • Mid-prefix stderr and stderr-only controls verified against GNU (gnu-3566-extra.sh).

Test plan

  • cargo build --locked --bin rubash
  • pin self-run 3/3 + fail-first red
  • GNU 5.3.20 script-file probes byte-match
  • cargo test --lib diff + -D warnings + marker-lint (flagged for captain)

…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
caomengxuan666 marked this pull request as ready for review November 17, 2026 15:47
@caomengxuan666
caomengxuan666 merged commit 9d00b56 into master Nov 17, 2026
8 of 12 checks passed
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.
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.

[bug] Windows prefix-concurrent pipeline drops the prefix's stdout when its last member wrote stderr

1 participant