diff options
author | Pádraig Brady <P@draigBrady.com> | 2023-03-05 15:51:32 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2023-03-08 18:32:05 +0000 |
commit | 16000805eb1bcdf25360471b8bbc8ec3f025e035 (patch) | |
tree | 62f3c3de4d34462cac20967433b827bc4cf9cb1e /NEWS | |
parent | 176b74f0e7360d94450c5aa3cf7db2ab86ed28c8 (diff) | |
download | coreutils-16000805eb1bcdf25360471b8bbc8ec3f025e035.tar.gz |
tee: support non blocking outputs
Non blocking outputs can be seen for example
when piping telnet through tee to a terminal.
In that case telnet sets its input to nonblocking mode,
which results in tee's output being nonblocking,
in which case in may receive an EAGAIN error upon write().
The same issue was seen with mpirun.
The following can be used to reproduce this
locally at a terminal (in most invocations):
$ { dd iflag=nonblock count=0 status=none;
dd bs=10K count=10 if=/dev/zero status=none; } |
tee || echo fail >/dev/tty
* src/iopoll.c (iopoll_internal): A new function refactored from
iopoll(), to also support a mode where we check the output
descriptor is writeable.
(iopoll): Now refactored to just call iopoll_internal().
(fwait_for_nonblocking_write): A new internal function which
uses iopoll_internal() to wait for writeable output
if an EAGAIN or EWOULDBLOCK was received.
(fwrite_nonblock): An fwrite() wrapper which uses
fwait_for_nonblocking_write() to handle EAGAIN.
(fclose_nonblock): Likewise.
src/iopoll.h: Add fclose_nonblock, fwrite_nonblock.
src/tee.c: Call fclose_nonblock() and fwrite_nonblock wrappers,
instead of the standard functions.
* tests/misc/tee.sh: Add a test case.
* NEWS: Mention the improvement.
The idea was suggested by Kamil Dudka in
https://bugzilla.redhat.com/1615467
Diffstat (limited to 'NEWS')
-rw-r--r-- | NEWS | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -172,6 +172,10 @@ GNU coreutils NEWS -*- outline -*- tee -p detects when all remaining outputs have become broken pipes, and exits, rather than waiting for more input to induce an exit when written. + tee now handles non blocking outputs, which can be seen for example with + telnet or mpirun piping through tee to a terminal. + Previously tee could truncate data written to such an output and fail, + and also potentially output a "Resource temporarily unavailable" error. * Noteworthy changes in release 9.1 (2022-04-15) [stable] |