<div dir="ltr"><div dir="ltr">On Sat, Dec 5, 2020, 3:38 AM Rob Landley <<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>> wrote:</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(Also, line buffering sucks because it'll flush at the buffer size anyway so<br>
you're not guaranteed to get a full line of contiguous output. What it REALLY<br>
wants is nagle's algorithm for stdout but no libc ever bothered to IMPLEMENT it,<br>
possibly because of the runtime expense... Ahem. My point is commands should<br>
probably do sane output blocking on their own.)</blockquote><div><br></div>AFAIK, the only way this would work is if libc only ever does nonblocking<br>writes to stdout, which also means it would need to spawn a thread or use<br>SIGIO to flush its buffer when stdout becomes available, plus modify the<br>flags on STDOUT_FILENO to be O_NONBLOCK (which doesn't even work on regular<br>files). I think people would be far more annoyed with this behavior than any<br>potential gains would justify?<br><br>(io_uring might make things more interesting, though? You could eliminate<br>libc's buffering entirely, and just memcpy and submit a write for every single<br><div>fwrite, up to some buffer limit.)</div></div></div>
</div>