diff --git a/src/win/tty.c b/src/win/tty.c index af828cf8..f0a00e1f 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -527,11 +527,16 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle, /* way that matters to libuv. */ if (handle->last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) { CONSOLE_SCREEN_BUFFER_INFO info; - if (uv_tty_output_handle == INVALID_HANDLE_VALUE) - continue; - if (!GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) - continue; - uv_tty_update_virtual_window(&info); + + EnterCriticalSection(&uv_tty_output_lock); + + if (uv_tty_output_handle != INVALID_HANDLE_VALUE && + GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) { + uv_tty_update_virtual_window(&info); + } + + LeaveCriticalSection(&uv_tty_output_lock); + continue; }