Skip to content

Commit 70a76db

Browse files
committed
fix: libuv can return UV_FILE or UV_TTY for FILE_TYPE_CHAR handles
1 parent a186035 commit 70a76db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/uv_mapping.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,13 @@ uvwasi_errno_t uvwasi__get_filetype_by_fd(uv_file fd, uvwasi_filetype_t* type) {
251251
if (r != 0) {
252252
uv_fs_req_cleanup(&req);
253253

254-
/* Windows can't stat a TTY. */
255-
if (uv_guess_handle(fd) == UV_TTY) {
254+
int guess;
255+
/*
256+
Windows can't stat a FILE_TYPE_CHAR, which is guessed
257+
as UV_TTY in "ConsoleMode" or UV_FILE otherwise.
258+
*/
259+
guess = uv_guess_handle(fd);
260+
if (guess == UV_TTY || guess == UV_FILE) {
256261
*type = UVWASI_FILETYPE_CHARACTER_DEVICE;
257262
return UVWASI_ESUCCESS;
258263
}

0 commit comments

Comments
 (0)