On Saturday, February 19, 2011 1:50:43 pm Jeremie Le Hen wrote:
> Hi,
> 
> I've been annoyed multiple time when running a command such like
>     iostat -x 1 | grep -v ad10 | cat -n
> 
> The problem stems from two factors:
>   - grep's stdio sees that its stdout is not a terminal, so stdout is
>     full buffered and not line-buffered;
>   - iostat produces output too slowly so the aforementioned buffer takes
>     numerous seconds to be filled and flushed to the last command.
> 
> This problems is not specific to FreeBSD, it is actually a consequence
> of POSIX specification.  I've checked this on Solaris and Linux.
> 
> I've attached a small patch for stdio, so if the environment variable
> STDIO_IOLBF is set, the output streams will be line-oriented by default.
>     iostat -x 1 | env STDIO_IOLBF=1 grep -v ad10 | cat -n
> 
> Before send it as a PR, I would like to hear your comments about this,
> especially:
>   - the variable name (no bikeshed please, I just ask this if there is a
>     naming convention I'm not aware of);
>   - the documentation: I've put a hint in stdio(3) manpage and put the
>     full explanation in setvbuf(3).

Many people would find this useful I think.

-- 
John Baldwin
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to