Skip to content

Commit

Permalink
fix: libuv can return UV_FILE or UV_TTY for FILE_TYPE_CHAR handles
Browse files Browse the repository at this point in the history
When uvwasi is used on Windows, it might be used in non-"ConsoleMode"
and the uv_guess_handle() function can return two different values for
FILE_TYPE_CHAR because of that difference.
  • Loading branch information
phated authored Dec 16, 2022
1 parent a186035 commit 6485e16
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/uv_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,13 @@ uvwasi_errno_t uvwasi__get_filetype_by_fd(uv_file fd, uvwasi_filetype_t* type) {
if (r != 0) {
uv_fs_req_cleanup(&req);

/* Windows can't stat a TTY. */
if (uv_guess_handle(fd) == UV_TTY) {
uv_handle_type guess;
/*
Windows can't stat a FILE_TYPE_CHAR, which is guessed
as UV_TTY in "ConsoleMode" or UV_FILE otherwise.
*/
guess = uv_guess_handle(fd);
if (guess == UV_TTY || guess == UV_FILE) {
*type = UVWASI_FILETYPE_CHARACTER_DEVICE;
return UVWASI_ESUCCESS;
}
Expand Down

0 comments on commit 6485e16

Please sign in to comment.