coreutils
coreutils copied to clipboard
cat: reading a closed stdin succeeds instead of failing with EBADF
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).