[Toybox] [PATCH] watch: flush the buffer each round.

Rob Landley rob at landley.net
Fri Mar 8 17:50:39 PST 2024


I remember when the xprintf() family would do a flush and check for errors each
write. That's why code like:

        dprintf(1, "%c", pad<cmdlen ? '*' : ' ');
        if (width) xputs(ss+(width>ctimelen ? 0 : width-1));
        if (yy>=3) dprintf(1, "\r\n");

Was allowable.

I also remember when we had an xflush() that would catch errors if stdout
barfed, instead of calling fflush() and ignoring the return code.

This code is mixing dprintf(1, ...) with printf() and fflush(stdout) in a way
that seems unlikely to end well, and I would like to think it through when I'm
not moving house. (Or have somebody whose brain isn't jello reassure me that
it's coherent.)

Ideally, I would wean it entirely off of the conceptually broken FILE * output
nonsense entirely to dprintf() and write(), because it's intentionally doing
progressive output and trying to micromanage cache management there is unending
pain. (We need a stdout with the nagle algorithm. Why did they only bother to do
that for network sockets?)

Rob


More information about the Toybox mailing list