Skip to content

Commit 48e4d45

Browse files
cjihrigcodebytere
authored andcommittedMar 17, 2020
deps: uvwasi: cherry-pick 7b5b6f9
Original commit message: allow windows to detect tty types uv_fs_fstat() fails on TTYs on Windows. This commit updates uvwasi__get_filetype_by_fd() to detect this case and map the fd to the WASI character device type. Refs: #31461 Fixes: #31461 PR-URL: #31495 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent e48f874 commit 48e4d45

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎deps/uvwasi/src/uv_mapping.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,15 @@ uvwasi_errno_t uvwasi__get_filetype_by_fd(uv_file fd, uvwasi_filetype_t* type) {
249249

250250
r = uv_fs_fstat(NULL, &req, fd, NULL);
251251
if (r != 0) {
252-
*type = UVWASI_FILETYPE_UNKNOWN;
253252
uv_fs_req_cleanup(&req);
253+
254+
/* Windows can't stat a TTY. */
255+
if (uv_guess_handle(fd) == UV_TTY) {
256+
*type = UVWASI_FILETYPE_CHARACTER_DEVICE;
257+
return UVWASI_ESUCCESS;
258+
}
259+
260+
*type = UVWASI_FILETYPE_UNKNOWN;
254261
return uvwasi__translate_uv_error(r);
255262
}
256263

0 commit comments

Comments
 (0)
Please sign in to comment.