stat: Use fstat when called with `-`/stdin as parameter (was MacOS CI: test_stat::test_stdin_pipe_fifo1/fifo2 are flaky)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
Seeing a bunch of MacOS test failures recently, in tests that call stat -.
Sometimes in test_stdin_pipe_fifo1 (in that test, stdin is set to std::process::Stdio::piped()):
thread 'test_stat::test_stdin_pipe_fifo1' panicked at tests/by-util/test_stat.rs:349:10:
Command was expected to succeed. code: 1
stdout =
stderr = stat: cannot stat '-': Bad file descriptor (os error 9)
Sometimes in test_stdin_pipe_fifo2 (in that test stdin in set to std::process::Stdio::null()), where - shows up as a weird file, instead of a character special file
---- test_stat::test_stdin_pipe_fifo2 stdout ----
run: /Users/runner/work/coreutils/coreutils/target/aarch64-apple-darwin/debug/coreutils stat -
thread 'test_stat::test_stdin_pipe_fifo2' panicked at tests/by-util/test_stat.rs:366:10:
' File: -
Size: 0 Blocks: 0 IO Block: 65536 weird file
Device: ffffffffbe5e09cfh/18446744072608418255d Inode: 334 Links: 1
Access: (0666/?rw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ wheel)
Access: 2025-03-26 13:31:00.961845000 +0000
Modify: 2025-03-26 13:31:00.831524000 +0000
Change: 2025-03-26 13:31:00.831524000 +0000
Birth: 1970-01-01 00:00:00.000000000 +0000
' does not contain 'character special file'
I'm a bit surprised that those tests are flaky (and not just always failing or passing). At least for the second one, we could try to understand what is that weird file.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tests/by-util/test_stat.rs, especially test_stdin_pipe_fifo1 and test_stdin_pipe_fifo2, and reproduce them on macOS. Trace how stat handles the '-' operand and compare the piped and null stdin cases. Done means the tests stop flaking and '-' consistently produces the expected character-special-file result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100