[Toybox] [PATCH] tr: fix pathological flushing.
Josh Gao
jmgao at google.com
Sat Dec 5 06:55:38 PST 2020
On Sat, Dec 5, 2020, 3:38 AM Rob Landley <rob at landley.net> wrote:
> (Also, line buffering sucks because it'll flush at the buffer size anyway
> so
> you're not guaranteed to get a full line of contiguous output. What it
> REALLY
> wants is nagle's algorithm for stdout but no libc ever bothered to
> IMPLEMENT it,
> possibly because of the runtime expense... Ahem. My point is commands
> should
> probably do sane output blocking on their own.)
AFAIK, the only way this would work is if libc only ever does nonblocking
writes to stdout, which also means it would need to spawn a thread or use
SIGIO to flush its buffer when stdout becomes available, plus modify the
flags on STDOUT_FILENO to be O_NONBLOCK (which doesn't even work on regular
files). I think people would be far more annoyed with this behavior than any
potential gains would justify?
(io_uring might make things more interesting, though? You could eliminate
libc's buffering entirely, and just memcpy and submit a write for every
single
fwrite, up to some buffer limit.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20201205/9099bb9e/attachment.htm>
More information about the Toybox
mailing list