Re: buffered output on solaris?

From: Jacek M. Holeczek (holeczek@us.edu.pl)
Date: Tue Jun 08 1999 - 09:58:27 MEST


> and execute it, nothing gets printed out. It takes a number of iterations
> of the function before anything gets printed out. However, if I do
This looks like a "buffering problem".
Usually, both stdout and stderr have their "buffers" ( for example 1kB to
4kB long ). When you "write" something, it goes into the buffer, and when
the buffer is full it's really written to the screen.
If you want to be sure that you get the text immediately, you need to
"fflush" the appropriate buffer ( or all, see "man fflush" for details ).
You could also lower the size of the "buffer", but it's not a good idea
( see "man setbuf,setbuffer,setlinebuf,setvbuf" for details ).
( If I remember well, flushing is also automatically done when you try to
get input from stdin. Also, I think, the stderr is line-buffered, so after
a newline character it's buffer is flushed, but I'm not sure now. )
( Note also - the exact behavior is system/compiler dependent. )
Jacek.
P.S. Of course, the same concerns also "regular" files, not only stdout,
     stderr. Jacek.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:34 MET