[Toybox] [PATCH] grep: add --line-buffered and fix regular buffering.

enh enh at google.com
Wed Apr 24 15:50:56 PDT 2019


On Wed, Apr 24, 2019 at 3:40 PM Rob Landley <rob at landley.net> wrote:
>
> On 4/23/19 8:06 PM, enh wrote:
> > (sorry. busy.)
>
> Sigh. I'll add a config symbol you can switch on, with help text complaining
> about it.

well, it's not necessarily grep i'm worried about. i think if all the
other toys are now going to be line-buffered, it doesn't make much
sense to single out grep like this.

> Does the attached work/suffice? (I _think_ setlinebuf(stdout) followed by
> setvbuf() something else is legal as long as we haven't output anything to the
> stream yet? But the man page is unclear. Presumably the admonition is because
> pending unflushed data in the buffer would get discarded, but they don't _say_...)

(POSIX explicitly says that it's only valid before any output, but
bionic [and BSDs] flush output data and discard input data if you call
setvbuf [and the others are implemented in terms of setvbuf].)

> Rob



More information about the Toybox mailing list