Skip to content

Commit

Permalink
Prevent duplicated login message (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
nullcatalyst committed Apr 2, 2020
1 parent 106db2b commit 8ab565c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contrib/win32/win32compat/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ ConEnterRawMode()
ScrollBottom = ConVisibleWindowHeight();

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 */
Expand Down

0 comments on commit 8ab565c

Please sign in to comment.