Skip to content

stat: Use fstat when called with -/stdin as parameter (was MacOS CI: test_stat::test_stdin_pipe_fifo1/fifo2 are flaky) #7583

@drinkcat

Description

@drinkcat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions