Skip to content

Commit 2586de1

Browse files
authored
Fix duplicate output on console resize event (#806)
* Fix the SIGWINCH interrupt makes the write operation think its failed, and causes it to try again. xlink directvt/vtm#819 (comment) > When a window resize event is received (terminal generates WINDOW_BUFFER_SIZE_EVENT event when switching between alternate/normal buffer mode), the errno becomes EINTR which causes the write operation think its failed. potentially fixes PowerShell/Win32-OpenSSH#2275 * #2275: Add comments to the fix the SIGWINCH interrupt makes the write operation think its failed
1 parent 803cf83 commit 2586de1

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

contrib/win32/win32compat/console.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,6 @@ ConEnterRawMode()
225225
ScrollBottom = ConVisibleWindowHeight();
226226

227227
in_raw_mode = 1;
228-
229-
/*
230-
Consume and ignore the first WINDOW_BUFFER_SIZE_EVENT, as we've triggered it ourselves by updating the console settings above.
231-
Not consuming this event can cause a race condition: the event can cause a write to the console to be printed twice as the
232-
SIGWINCH interrupt makes the write operation think its failed, and causes it to try again.
233-
*/
234-
INPUT_RECORD peek_input;
235-
int out_count = 0;
236-
if (PeekConsoleInputW(GetConsoleInputHandle(), &peek_input, 1, &out_count) && peek_input.EventType == WINDOW_BUFFER_SIZE_EVENT) {
237-
ReadConsoleInputW(GetConsoleInputHandle(), &peek_input, 1, &out_count);
238-
}
239228
}
240229

241230
/* Used to Uninitialize the Console */

contrib/win32/win32compat/signal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ sw_process_pending_signals()
228228
if (sigismember(&pending_tmp, exp[i])) {
229229
if (sig_handlers[exp[i]] != W32_SIG_IGN) {
230230
w32_raise(exp[i]);
231-
/* dont error EINTR for SIG_ALRM, */
232-
/* sftp client is not expecting it */
233-
if (exp[i] != W32_SIGALRM)
231+
/* don't set errno=EINTR on SIGALRM, sftp client is not expecting it */
232+
/* don't set errno=EINTR on SIGWINCH in order to avoid breaking the sequence of waiting for completion of IO operations. */
233+
if (exp[i] != W32_SIGALRM && exp[i] != W32_SIGWINCH)
234234
sig_int = TRUE;
235235
} else if (exp[i] == W32_SIGCHLD) /*if SIGCHLD is SIG_IGN, reap zombies*/
236236
sw_cleanup_child_zombies();

0 commit comments

Comments
 (0)