Skip to content

Commit 4df1ba8

Browse files
committed
common-main.c: fflush stdout buffer when exit
By default, the buffer type of Windows' stdout is no buffer (_IONBF), and there is no need to manually fflush stdout. But some program, such as Windows Filtering Platform driver provided by the security software, may change the buffer type of stdout to Full buffering. Therefore, fflush(stdout) needs to be called manually, otherwise there will be no output to stdout. According to common sense, when the program exits, the stdout buffer should be automatically output and released, but not on Windows. So this commit will do it. Signed-off-by: MinarKotonoha <chengzhuo5@qq.com>
1 parent ad0bbff commit 4df1ba8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

common-main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ static void check_bug_if_BUG(void)
7575
/* We wrap exit() to call common_exit() in git-compat-util.h */
7676
int common_exit(const char *file, int line, int code)
7777
{
78+
/*
79+
* Windows Filtering Platform driver provided by the security software
80+
* may change buffer type of stdout from _IONBF to _IOFBF.
81+
* It will no output without fflush manually.
82+
*/
83+
fflush(stdout);
84+
7885
/*
7986
* For non-POSIX systems: Take the lowest 8 bits of the "code"
8087
* to e.g. turn -1 into 255. On a POSIX system this is

0 commit comments

Comments
 (0)