Skip to content

head: continue after per-file read error#12308

Open
rossilor95 wants to merge 2 commits into
uutils:mainfrom
rossilor95:head-continue-after-read-error
Open

head: continue after per-file read error#12308
rossilor95 wants to merge 2 commits into
uutils:mainfrom
rossilor95:head-continue-after-read-error

Conversation

@rossilor95
Copy link
Copy Markdown
Contributor

Fixes #11846.

head now reports per-file read errors correctly and continues processing the remaining input files.

Previously, reading from files like /proc/self/mem could be reported as a standard output write error because io::copy mixed read and write failures into the same error path.

This change keeps read errors associated with the input file, while preserving stdout write error handling.

Comment thread src/uu/head/src/head.rs
loop {
let n = match reader.read(&mut buf) {
Ok(0) => break,
Ok(n) => n,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you avoid same letter n?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and avoid one letter variable :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single letter variable is idiomatic for a variable bound by a pattern, but the outer variable should be named something like bytes_read.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/head/head-write-error. tests/head/head-write-error is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tail/follow-name (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/symlink (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 15, 2026

Merging this PR will degrade performance by 3.91%

❌ 1 regressed benchmark
✅ 316 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation ls_recursive_balanced_tree[(6, 4, 15)] 48.9 ms 50.9 ms -3.91%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rossilor95:head-continue-after-read-error (f8778ad) with main (873a7c7)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

head: head /proc/self/men file does not show content of file

4 participants