coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

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

Open ozenyunus35 opened this issue 1 month ago • 0 comments

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).

ozenyunus35 avatar Oct 12 '26 13:10 ozenyunus35