Skip to content

cat: reading a closed stdin succeeds instead of failing with EBADF #15278

Closed

Description

@ozenyunus35

When cat is started with stdin closed, it treats the input as empty and exits with status 0. GNU cat reports the error and exits with 1:

$ sh -c 'exec <&-; cat'
cat: -: Bad file descriptor
$ echo $?
1

uutils cat prints nothing and exits 0, because the Rust runtime reopens a closed fd 0 as /dev/null before main runs.

This is one of the cases in the GNU test misc/close-stdin.sh (tracked in #14705).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions