Skip to content

fix(cat): short ReadFile on pipe/console stdin so fast_passthrough streams - #1286

Merged
caomengxuan666 merged 1 commit into
unixwin:mainfrom
Catapult291:fix/cat-stream-short-read-pipe-stdin
Oct 23, 2026
Merged

caomengxuan666 merged 1 commit into
unixwin:mainfrom
Catapult291:fix/cat-stream-short-read-pipe-stdin

Conversation

@Catapult291

Copy link
Copy Markdown
Collaborator

Summary

cat with no operands used istream::read(buffer, 8192) in fast_passthrough. MSVC xsgetn fills the buffer or EOF, so a dribbling pipe producer (python … | cat) delivered the first chunk only at EOF.

Changes

  • If stdin is std::cin and the handle type is FILE_TYPE_PIPE / FILE_TYPE_CHAR, use a single ReadFile (short read) and safePrint each chunk.
  • Disk files keep the filled 8192 loop (data always available).

Pairs with rubash pipeline streaming PR. Shell-independent repro: python parent + this cat showed first byte at ~3s before, ~0.03s after.

Niubash defect log D4 (WinuxCmd layer), 2026-10-23.

@caomengxuan666
caomengxuan666 merged commit 7176900 into unixwin:main Oct 23, 2026
8 checks passed
@caomengxuan666

Copy link
Copy Markdown
Member

Thanks — good catch. The istream read blocking until the buffer fills is exactly why python … | cat felt broken, and the before/after (first byte at ~3s vs ~0.03s) is the whole story. Splitting pipe/console from the disk-file loop is the right call: filled reads stay the fast path when the data is already there. Merged; looking forward to the rubash-side streaming piece pairing with this.

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.

2 participants