lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> Because ANSI C says that stdout is line buffered? At least I thought so but
> some people disagree:
> So, yes, perhaps it's best to fflush(stdout) after all, just in case.

Well I was also miss leaded by some posts, but I found another one that have actual references on the C99 specification:
C99, 7.19.3 Files, paragraph 7 and
Basically it says that at program startup stdout is opened as a full buffered file unless it is connected to an interactive device...

I actually verified this behavior doing a simple&stupid C program:

#include <stdio.h>
int main()
    //setvbuf(stdout, (char *) NULL, _IOLBF, 0);
    while (1)
    return 0;

When running 'test' in a shell shows that the new line appears every seconds

However running 'test > somefile' will not feed the file, unless I uncomment the setvbuff line :)