You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tee: handle short writes to stdout correctly #14981
tee does not correctly handle short writes to stdout when stdout is a regular file on Linux.
The GNU tee/short-write.sh test expects short writes to be retried until the remaining data is written, but the current implementation uses the splice path for regular-file stdout, bypassing the injected write(2) short writes.
We should ensure that short writes to regular-file stdout are handled correctly.
I think so. But it is bit tricky to the test meaningful for splice(2) path. I'd like to patch to fail splice path at fallback to write path at a moment.
retval=1 for write(2) means write(2) returns 1 without actually writing. So next read(2) consumes buffer. Then we lost "a". So we lost "a" by previous read(2). It is expected and used at GnuTests.
retval=1 for splice(2) means splice(2) returns 1 without actually sending. So pipe buffer is NOT changed. It is "correct" behaviour. Then we see "a" after all retval'ed call finished since it is still in pipe buffer.
Activity
xtqqczze commentedon Sep 30, 2026
taken by @mattsu2020
oech3 commentedon Sep 30, 2026
Difference of used syscall is not a problem if the used syscall is an optional dependency.
We can patch GnuTests in this case to support our syscall.
mattsu2020 commentedon Sep 30, 2026
Should we update the GNU test to use splice instead?
oech3 commentedon Sep 30, 2026
I think so. But it is bit tricky to the test meaningful for splice(2) path. I'd like to patch to fail splice path at fallback to write path at a moment.
It is done by adding
-e fault=splice.oech3 commentedon Sep 30, 2026
oech3 commentedon Sep 30, 2026
We could use named pipe with 1 byte remain to cause short-write. But it would be too complex.
oech3 commentedon Oct 7, 2026
I think it is impossible to do same strace test for
splice(2)sincestraceis a tool to modify returned value, not a len passed tosplice(2).mattsu2020 commentedon Oct 7, 2026
How about changing the test to something like the following?
oech3 commentedon Oct 7, 2026
oech3 commentedon Oct 7, 2026
#14981 (comment) tests write code path only.
oech3 commentedon Oct 7, 2026
oech3 commentedon Oct 7, 2026
OK. So splice(2) and write(2) are very different.
So next read(2) consumes buffer. Then we lost "a".So we lost "a" by previousread(2). It is expected and used at GnuTests.oech3 commentedon Oct 8, 2026
I fixed the previous comment about read.