https://bugs.winehq.org/show_bug.cgi?id=56459
--- Comment #8 from Eric Pouech eric.pouech@gmail.com --- (In reply to renatopereyra from comment #6)
I sent my comment too soon. I forgot to mention two more things.
I also tested whether the buffering of stdout meant that the output to a file would be incomplete if a process is killed. I tried this by printing 8000 chars to stdout with the test app I shared and killing the process from the Windows Task Manager. I found that the characters after the first 4096 were written to the file when the process was killed. This means that it seems that Windows always flushes all output, even when the process is killed. This is different from Wine behavior too.
I'll try some tests on this one, but the only way this could happen is if the app is smoothly terminated (ie the msvcrt atexit handlers or equiv are called). I very much doubt that TerminateProcess() will do the same. So this shall be tested with the same way of terminating between Wine and Windows.
./wine [[your exec and args]] < /dev/null 2>&1 | cat -
- The ordering of the output to the terminal appears to be stdout first and stderr second. They are not interleaved as I might have expected. Is it possible to interleave the output depending on the time the print actually happened?
by default (msvcrt), stdout is buffered while stderr isn't. it tested a loop ``` for (int i = 0; i < 1000; i++) { fprintf(stdout, "stdout %i\n", i); fprintf(stderr, "stderr %i\n", i); Sleep(100); } ``` lines from stderr are printed, until stdout buffer is full (its content is printed in bulk), then stderr keeps on printing and so...
so to achieve what you want, you need to: - either unbuffer stdout (that's at application level: setvbuf(stdout, NULL, _IONBF, 0); - or stop printing to both stderr and stdout and use only one them
moreover, what you seem to want is line buffering (ie ensuring a line up to \n is printed at once); this is defined in CRT with _IOLBF flag to setvbuf. Sadly, native Windows CRT implements _IOLBF as _IOFBF, so it won't be of any help here.