Rework stdout buffering on Windows.

Windows doesn't support line-buffering. We enable full-buffering instead and flush buffers per module.
This commit is contained in:
李通洲
2022-12-14 16:27:04 +08:00
parent d151901049
commit e4a5194115
7 changed files with 22 additions and 19 deletions
+6
View File
@@ -354,6 +354,9 @@ void ffStart(FFinstance* instance)
ffHideCursor = instance->config.hideCursor && !instance->config.pipe;
#ifdef _WIN32
#ifdef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IOFBF, 4096);
#endif
SetConsoleCtrlHandler(consoleHandler, TRUE);
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode = 0;
@@ -361,6 +364,9 @@ void ffStart(FFinstance* instance)
SetConsoleMode(hStdout, mode | ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
SetConsoleOutputCP(CP_UTF8);
#else
#ifndef FF_ENABLE_BUFFER
setvbuf(stdout, NULL, _IONBF, 0);
#endif
struct sigaction action = { .sa_handler = exitSignalHandler };
sigaction(SIGINT, &action, NULL);
sigaction(SIGTERM, &action, NULL);