cat: fallback on EBADF with copy_file_range(2)

When stdout is opened with O_APPEND, copy_file_range(2) fails with EBADF.
This commit is contained in:
Martin Matuska 2023-07-09 01:04:25 +02:00
parent 2596008a0b
commit 055f920ebe

View file

@ -283,7 +283,7 @@ scanfiles(char *argv[], int cooked __unused)
} else {
#ifndef BOOTSTRAP_CAT
if (in_kernel_copy(fd) == -1) {
if (errno == EINVAL)
if (errno == EINVAL || errno == EBADF)
raw_cat(fd);
else
err(1, "stdout");