Skip to content

stat . > /dev/full panics#13401

Open
Devel08 wants to merge 3 commits into
uutils:mainfrom
Devel08:fix-issue-10559
Open

stat . > /dev/full panics#13401
Devel08 wants to merge 3 commits into
uutils:mainfrom
Devel08:fix-issue-10559

Conversation

@Devel08

@Devel08 Devel08 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

closes #10559

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/pr/bounded-memory (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/follow-name (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/expand/bounded-memory is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

Comment thread src/uu/stat/src/stat.rs
Token::Char(c) => print!("{c}"),
Token::Char(c) => std::io::stdout()
.write_all(c.to_string().as_bytes())
.map_err(|_| 1)?,

@xtqqczze xtqqczze Jul 16, 2026

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.

We should emit an error message, to match GNU Coreutils

@Devel08 Devel08 Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

well, we can do something like

            Token::Char(c) => {
                if let Err(e) = std::io::stdout().write_all(c.to_string().as_bytes()) {
                    show_error!("{}", strip_errno(&e));
                    std::process::exit(1);
                }
            }

but CONTRIBUTING.md says to avoid std::process::exit, however the output will be stat: No space left on device

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cakebaker What do you think, is it safe to use std::process::exit here? Sorry for mention

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 return Err(1); work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, as it will print out the os error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No, please refrain from using std::process::exit.
Instead, maybe you can propagate the error of write_all(() ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nope, as it will print out the os error

Isn't it what we want to do ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope, as it will print out the os error

Isn't it what we want to do ?

Nope, that's what I did at first

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.

propagate the error of write_all(()

that would be ideal, but would require a much larger refactoring as uu_stat function result types generally use i32 instead of an actual error type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess we should go with a refactoring then, returning a simple i32 is not really rust-idiomatic.

@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 231 untouched benchmarks
⏩ 154 skipped benchmarks1


Comparing Devel08:fix-issue-10559 (819b9eb) with main (ef50d8b)

Open in CodSpeed

Footnotes

  1. 154 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.

stat . > /dev/full panics

4 participants