Daniel Raymond <danr@...> writes:
> I've written some code and compiled it using MinGW. When I execute
> the code in an MSYS window I don't see any of the output from my
> printf() statements until the program exits and then all of it gets
> dumped to the screen at once. When I run the same program in a UWIN
> window or from a standard command console (CMD.EXE) the output is
> displayed immediately while the program is running. Is this a bug
> in MSYS?
Sounds like full buffering with MSYS and line buffering in the other
You can set the buffering mode yourself in your program, see the
setvbuf() function and use that with stdout.
[*] The C runtime decides the buffering defaults for stdout based on
the result of isatty(). If isatty() is true, you get line buffering
for interactive use, if it is false, indicating a file or a pipeline,
you get full buffering for speed.
On Unix, shells can use pseudo-ttys where necessary (inducing isatty()
to return true) to force interactive, line buffered mode. But Windows
doesn't have pseudo-ttys, so isatty() returns 0, giving full buffering
with these shells. With an actual MSYS program that wouldn't happen,
because isatty() is implemented differently in MSYS.