Mail Archives: djgpp/1997/09/15/07:40:19
On Sun, 14 Sep 1997, Nate Eldredge wrote:
> At 05:17 9/13/1997 GMT, Paul Derbyshire wrote:
> >
> >Unlike Borland, DJGPP line-buffers stdio. Add fflush(stdout) after the
> >printf's in the loop (or a \n at the end of the line) and all
> >should work.
>
> Not entirely correct... stdout is not line buffered, but fully buffered. And
> the buffer is 4K in size. So adding a \n will not help.
No, Nate, Paul was right: stdout *is* line-buffered *if* it is
connected to the console device. So if \n is added, it *will* output
the string immediately. If stdout is redirected to a file or a pipe,
then it is indeed fully buffered, but as far as I can see, the buffer
size is the size of the transfer buffer, not 4K.
(`stdout' is initialized as fully buffered, but the first time it is
actually used, the buffering is changed to line-buffering if it is
connected to a console. See src/libc/ansi/stdio/flsbuf.c in the
library sources.)
- Raw text -