How do I keep a pipe from buffering I/O?

Bert Bos bert at let.rug.nl
Wed Feb 27 08:01:32 AEST 1991


I tried to fork a process and redirect both input and output to pipes.
Both processes could work in parallel and as soon as one of the two
had some text ready, it would be written out on the pipe for the other
process to read. One of the processes could even be a program such as
Awk (started with exec()).

Problem is, the pipes appear to buffer such large amounts of text,
that one process only gets input after the other has already finished.
How do I force the pipes to pass on text one line at a time?

I'm using calls such as pipe(), dup2(), select(), read(), etc, but I
couldn't find anything in the manuals.
-- 
  "Always remember, however, that there's     Bert Bos (bert at let.rug.nl)
   usually a simpler and better way to do     Alfa-informatica
   something than the first way that pops     RijksUniversiteit Groningen
   into your head." (D.E. Knuth, TeXbook)     Groningen, The Netherlands



More information about the Comp.unix.programmer mailing list