Stdio buffering question

Wayne Hathaway ultra!wayne at ames.arc.nasa.gov
Fri Jun 10 09:46:43 AEST 1988


I hate to bother Wizards with what is probably a very simple question,
but it stumps me.  I have this very simple program that periodically
does an fprintf(stderr,...) to indicate progress.  The  messages show
up as written, as expected.  Now I want to pipe this output through
awk.  This works fine, EXCEPT that all the lines are buffered in the
originating process until it exits, then they all blast out at once.
I realize I can put fflush()s in the original program, but isn't that
against the "filters" philosophy?  I mean, if it doesn't buffer when
writing to the terminal, why does it buffer when writing to a pipe?

I have done nothing special in the program about buffering, by the
way, and the environment is SunOS 3.3.

Thanx for any enlightenment!

      Wayne Hathaway                  ultra!wayne at Ames.ARPA
      Ultra Network Technologies
      2140 Bering drive               with a domain server:
      San Jose, CA 95131                 wayne at Ultra.COM
      408-922-0100



More information about the Comp.unix.wizards mailing list