diff --git a/include/uv-private/uv-win.h b/include/uv-private/uv-win.h index 8c1cf731..f45ce2b0 100644 --- a/include/uv-private/uv-win.h +++ b/include/uv-private/uv-win.h @@ -383,7 +383,6 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s); union { \ struct { \ /* Used for readable TTY handles */ \ - HANDLE output_handle; \ HANDLE read_line_handle; \ uv_buf_t read_line_buffer; \ HANDLE read_raw_wait; \ diff --git a/src/win/tty.c b/src/win/tty.c index 0cb40880..8575f4f7 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -90,7 +90,6 @@ void uv_console_init() { int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { HANDLE handle = INVALID_HANDLE_VALUE; - HANDLE output_handle = INVALID_HANDLE_VALUE; DWORD original_console_mode = 0; CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info; @@ -107,41 +106,20 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { return -1; } - /* Both readable and writable handles need access to the console output. */ - /* If the given fd is readable then we need to open the output handle */ - /* separately. */ - output_handle = CreateFileW(L"CONOUT$", - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL); - if (output_handle == INVALID_HANDLE_VALUE) { - uv__set_sys_error(loop, GetLastError()); - return -1; - } - - /* Obtain the screen buffer info with the output handle. */ - if (!GetConsoleScreenBufferInfo(output_handle, &screen_buffer_info)) { - uv__set_sys_error(loop, GetLastError()); - CloseHandle(output_handle); - return -1; - } - } else { /* Obtain the screen buffer info with the output handle. */ if (!GetConsoleScreenBufferInfo(handle, &screen_buffer_info)) { uv__set_sys_error(loop, GetLastError()); return -1; } + + /* Update the virtual window. We must hold the tty_output_lock because the */ + /* virtual window state is shared between all uv_tty handles. */ + EnterCriticalSection(&uv_tty_output_lock); + uv_tty_update_virtual_window(&screen_buffer_info); + LeaveCriticalSection(&uv_tty_output_lock); } - /* Update the virtual window. We must hold the tty_output_lock because the */ - /* virtual window state is shared between all uv_tty handles. */ - EnterCriticalSection(&uv_tty_output_lock); - uv_tty_update_virtual_window(&screen_buffer_info); - LeaveCriticalSection(&uv_tty_output_lock); uv_stream_init(loop, (uv_stream_t*) tty, UV_TTY); uv_connection_init((uv_stream_t*) tty); @@ -152,7 +130,6 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { if (readable) { /* Initialize TTY input specific fields. */ - tty->output_handle = output_handle; tty->original_console_mode = original_console_mode; tty->flags |= UV_HANDLE_TTY_READABLE; tty->read_line_handle = NULL; @@ -1796,7 +1773,6 @@ void uv_tty_close(uv_tty_t* handle) { if (handle->flags & UV_HANDLE_TTY_READABLE) { /* Readable TTY handle */ uv_tty_read_stop(handle); - CloseHandle(handle->output_handle); } else { /* Writable TTY handle */ handle->flags |= UV_HANDLE_SHUTTING;