Quote:
Originally posted by serge
By defalt stdout is "line - buffered".
It mean that after printf("...\n") buffer was flushed if output to stdout.
Certainly the file I/O buffers isn't "line-buffered", and before fork(), buffers was not flushed. So its filled buffers was copied.
What happen if we write " for(int i = 0 ; i < 3; ++i) " ?
You can manage I/O buffering by using "setvbuf" function.
Do you mean when OS invoke printf(),it will invoke setbuf()?
and does it mean that setbuf() will set a buffer flag to determine
if it is line-buffered or block-buffered?
i have traced in C++ code when it invoke setbuf(),but i still can't find where it set flag?
i wanna thank all the people who reply to my question!!!