[Toybox] Sigh. What needed setlinebuf(break_everything) again?

Rob Landley rob at landley.net
Sat Nov 21 08:01:29 PST 2020

On 11/21/20 9:52 AM, Rob Landley wrote:
> Because it broke watch. (When you fill the screen it never displays the last
> line of output until you hit "q".) And it broke tee, and it broke...
> Why did it go in again? What was the problem being solved? I've noticed that I'm
> using a lot more dprintf(1, "blah") these days just to prevent having to deal
> with the fact that xprintf() got broken and no longer actually produces output
> until random future things happen...

It's because adding a --line-buffered option seemed crazy:


And because xprintf() got nerfed to be useless (not actually flush). Watch is
actually calling xprintf(), it just doesn't _matter_.

Great: stdout needs nagle's algorithm.

Does anything OTHER than sed and grep care about this particular performance
weirdness? I remember adding this buffering broke password prompts, and I really
kind of want it to die in a fire. I _am_ tempted to replace every printf with
dprintf(1, ) just because THAT WORKS RELIABLY and what we're doing does not.

(The two hard problems in computer science remain cache invalidation, naming
things, and off by one errors. Unnecessary buffering is premature optimization.)

> Rob


More information about the Toybox mailing list