How do I get lines from a pipe as they are written instead of only in

How do I get lines from a pipe as they are written instead of only in


The stdio library does buffering differently depending on whether
it thinks it's running on a tty. If it thinks it's on a tty, it
does buffering on a per-line basis; if not, it uses a larger
buffer than one line.

If you have the source code to the client whose buffering you
want to disable, you can use setbuf() or setvbuf() to change the
buffering.

If not, the best you can do is try to convince the program that
it's running on a tty by running it under a pty, e.g. by using
the "pty" program mentioned in question 3.9.



Home FAQ