UNIX FAQ Version 2.1 92/12/04 -- Question 3.14

UNIX FAQ Version 2.1 92/12/04 -- Question 3.14

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

From: jik@pit-manager.MIT.Edu (Jonathan I. Kamens)

Date: Sun, 16 Feb 92 20:59:28 -0500

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.