diff --git a/src/uv_mapping.c b/src/uv_mapping.c index 297fdf5..da922de 100644 --- a/src/uv_mapping.c +++ b/src/uv_mapping.c @@ -249,8 +249,15 @@ uvwasi_errno_t uvwasi__get_filetype_by_fd(uv_file fd, uvwasi_filetype_t* type) { r = uv_fs_fstat(NULL, &req, fd, NULL); if (r != 0) { - *type = UVWASI_FILETYPE_UNKNOWN; uv_fs_req_cleanup(&req); + + /* Windows can't stat a TTY. */ + if (uv_guess_handle(fd) == UV_TTY) { + *type = UVWASI_FILETYPE_CHARACTER_DEVICE; + return UVWASI_ESUCCESS; + } + + *type = UVWASI_FILETYPE_UNKNOWN; return uvwasi__translate_uv_error(r); }