Skip to content

Commit

Permalink
win, tty: fix uv_tty_close
Browse files Browse the repository at this point in the history
Under some condition, uv_tty_close would not stop console reads. This
fixes that issue by first stopping read, then closing the handle.

Ref: nodejs/node#22999
  • Loading branch information
bzoz committed Sep 27, 2018
1 parent b9a0840 commit 785fd47
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/win/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 785fd47

Please sign in to comment.