Skip to content

fix(pipeline): stream last-stage host stdout live; keep capture/redirect collecting - #1445

Merged
caomengxuan666 merged 1 commit into
unixwin:masterfrom
Catapult291:fix/pipeline-stream-host-stdout
Oct 24, 2026
Merged

caomengxuan666 merged 1 commit into
unixwin:masterfrom
Catapult291:fix/pipeline-stream-host-stdout

Conversation

@Catapult291

Copy link
Copy Markdown
Contributor

Summary

A | B buffered the entire last-stage stdout and wrote it only after all members were reaped (~seconds for a 1-line/s producer).

Changes

  • PipelineDrainTarget::{Collect,StreamHostStdout}: when the last stage's fd1 is direct host stdout, pump 16KB chunks live via write_real_stdout_uncaptured; first host write error is recorded but drain continues (avoid niubash#158-style deadlock).
  • final_member_stdout_streams_to_host: any redirect, fd1 close, shell-writer capture, $(), or executor capture → Collect (unchanged semantics).
  • Regressions: tests/pipeline_streaming_regressions.rs.

Related: #158, #761. Pair with WinuxCmd cat short-read PR (MSVC xsgetn was the second layer for | cat).

Note: bash -c '<pipeline>' shares this path because bash/sh are hardlinks to niu (niubash #397); no extra special case.

Test plan

Probe After
python lines.py | cat first line ~0.03–0.05s (was ~3s)
bash -c '<pipeline>' ~0.04s
$(python lines.py | cat) capture correct; no leak to host
yes | head -3 PIPESTATUS 141 0
existing issue158/144/345/440/761 green

Niubash defect log D4 (2026-10-23).

@jhermelink

Copy link
Copy Markdown
Contributor

Related: #1454.

This PR fixes the buffering part (the last member's output now reaches the host live). The last member still gets a capture pipe as its stdout (process.stdout(Stdio::piped()) is unchanged), so it can never detect a terminal and cmd | less still doesn't page. #1454 tracks letting the last member inherit the shell's stdout when that is the console.

@caomengxuan666
caomengxuan666 merged commit 95ecff0 into unixwin:master Oct 24, 2026
2 checks passed
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.

3 participants