Skip to content

Commit

Permalink
deps: uvwasi: cherry-pick 7b5b6f9
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
cjihrig authored and codebytere committed Feb 17, 2020
1 parent 3046648 commit 2eeaa5c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion deps/uvwasi/src/uv_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2eeaa5c

Please sign in to comment.