Why doesn't "cat a b > foo" work?

Grant Edwards grant.b.edwards at gmail.com
Tue Jan 19 20:48:25 UTC 2021


On 2021-01-19, Grant Edwards <grant.b.edwards at gmail.com> wrote:
> We recently upgraded from an older version of busybox to 1.31.0, and
> now there seems to be a problem with 'cat'. If I cat two files to
> stdout it works fine, but if I redirect output into a file using ash,
> the second file overwrites the first:
>
>     # echo abcdefghijk > a
>     # echo 12345 > b
>     
>     # cat a b
>     abcdefghijk
>     12345
>     
>     # cat a b > bar
>     # cat bar
>     12345
>     ghijk
>     
>     # cat a b | cat > bar
>     # cat bar
>     abcdefghijk
>     12345
>[...]
> I wonder if the use of sendfile64() is new, and sendfile64() doesn't
> work right in our libc.

I've confirmed that with our older version of busybox (1.26?) 'cat'
doesn't use sendfile() for the test case above (which works
fine). AFAICT from the strace output the sendfile64() call is made
correctly, so it must be a kernel problem and not a gcc or libc
problem.

--
Grant






More information about the busybox mailing list