Pádraig Brady wrote:

> It's probably useful to add this functionality to all coreutil filters.
> I still need to be convinced that glibc is not the correct place for this.
> If it was there then any users of stdio could be controlled.

It has been said before in previous threads but I want to re-state that
this is possible in a very simple and general way with the LD_PRELOAD facility:

$ echo '__attribute__((constructor)) void f() { setvbuf (stdout, NULL, _IOLBF, 
0); }' | \
  gcc -include stdio.h -x c - -fPIC -shared -o linebuf.so

$ ( while true; do echo "foo"; sleep 1; done ) | LD_PRELOAD=./linebuf.so grep 
foo | cat
foo
foo
foo
... # immediate output

Brian


Reply via email to