From 785fd4725774046ce1cb05194bc61b0ffe88f3ec Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 27 Sep 2018 11:51:49 +0200 Subject: [PATCH] win, tty: fix uv_tty_close Under some condition, uv_tty_close would not stop console reads. This fixes that issue by first stopping read, then closing the handle. Ref: https://github.com/nodejs/node/issues/22999 --- src/win/tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win/tty.c b/src/win/tty.c index dacb8a8269c..32ccf74ca8c 100644 --- a/src/win/tty.c +++ b/src/win/tty.c @@ -2180,14 +2180,14 @@ void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle, void uv_tty_close(uv_tty_t* handle) { assert(handle->u.fd == -1 || handle->u.fd > 2); + if (handle->flags & UV_HANDLE_READING) + uv_tty_read_stop(handle); + if (handle->u.fd == -1) CloseHandle(handle->handle); else close(handle->u.fd); - if (handle->flags & UV_HANDLE_READING) - uv_tty_read_stop(handle); - handle->u.fd = -1; handle->handle = INVALID_HANDLE_VALUE; handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);