Prevent duplicated login message (#426)

This commit is contained in:
Scott Bennett 2020-04-02 17:34:30 -04:00 committed by GitHub
parent 106db2baac
commit 8ab565c53f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -221,6 +221,17 @@ ConEnterRawMode()
ScrollBottom = ConVisibleWindowHeight(); ScrollBottom = ConVisibleWindowHeight();
in_raw_mode = 1; in_raw_mode = 1;
/*
Consume and ignore the first WINDOW_BUFFER_SIZE_EVENT, as we've triggered it ourselves by updating the console settings above.
Not consuming this event can cause a race condition: the event can cause a write to the console to be printed twice as the
SIGWINCH interrupt makes the write operation think its failed, and causes it to try again.
*/
INPUT_RECORD peek_input;
int out_count = 0;
if (PeekConsoleInputW(GetConsoleInputHandle(), &peek_input, 1, &out_count) && peek_input.EventType == WINDOW_BUFFER_SIZE_EVENT) {
ReadConsoleInputW(GetConsoleInputHandle(), &peek_input, 1, &out_count);
}
} }
/* Used to Uninitialize the Console */ /* Used to Uninitialize the Console */