Skip to content

WIP: fix(head): fifo operands stream from the pipe HANDLE, stop at the Nth delimiter (#1442) - #1448

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/1442-head-fifo
Oct 29, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/1442-head-fifo

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Fix for #1442, draft for CI adjudication. Main session closes the issue after verification.

Refs #1442

What

Fifo operands are named pipes behind on-disk markers. The ifstream paths poison them: the seek-based text-decode probe fails tellg/seekg on pipes (partial writer yields silent zero output) and the decode path reads to EOF instead of stopping at the Nth delimiter. This routes fifo operands to short ReadFile reads on the pipe HANDLE, mirroring the stdin fast path (#1289/R2), covering line, byte, -z and all-but-last faces. Bytes pass through raw, as GNU does on pipes.

Regression pins (tests/unit/head/head_unit_test.cpp)

  • fifo operand truncates at first line (tee writer)
  • partial writer still prints first line
  • stops at delimiter without EOF: 256 KiB writer input exceeds the 64 KiB pipe buffer, so head must close the read end early and tee must die with a write error (writer rc 1) — this is the streaming proof, not just the EOF case
  • byte mode guard, -z guard, all-but-last lines guard

… delimiter (#1442)

Fifo operands are named pipes behind on-disk markers; the ifstream
paths poison them: the seek-based text-decode probe fails tellg/seekg
on pipes (partial writer yields silent zero output) and the decode path
reads to EOF instead of stopping at the Nth delimiter. Route fifo
operands to short ReadFile reads on the pipe HANDLE, mirroring the
stdin fast path (#1289/R2), covering line, byte, -z and all-but-last
faces. Bytes pass through raw, as GNU does on pipes.

Refs #1442
#1442)

-c 4 over 'l1\nl2\n' is 'l1\nl' (6c 31 0a 6c), not 'l1\n': the
previous expectation miscounted. The product output already matched
GNU 9.4; only the test's rhs was wrong (CI run 40956904491, test #1264).

Refs #1442
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 29, 2026 22:20
@caomengxuan666
caomengxuan666 merged commit 11b312b into main Oct 29, 2026
8 of 9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1442-head-fifo branch October 30, 2026 01:42
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.

1 participant