authorgravatar for takeshi@tetrate.ioTakeshi Yoneda <takeshi@tetrate.io> 2022-12-11 17:44:38+09:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-12-11 03:44:38-05:00
log78ea270cc63197e4af312463d4f0c5490285d6ba
tree6ae6236e5a31b8ade8f6cfde47979c8d2ed34455
parentcffbb32d31495c83addae7ed3882dc000fb327aa
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

wasi: fixes os.isatty on type mismatch (#13813)


2 files changed, 9 insertions(+), 1 deletions(-)

lib/std/os.zig+1-1
...@@ -3158,7 +3158,7 @@ pub fn isatty(handle: fd_t) bool {...@@ -3158,7 +3158,7 @@ pub fn isatty(handle: fd_t) bool {
3158 if (builtin.os.tag == .wasi) {3158 if (builtin.os.tag == .wasi) {
3159 var statbuf: fdstat_t = undefined;3159 var statbuf: fdstat_t = undefined;
3160 const err = system.fd_fdstat_get(handle, &statbuf);3160 const err = system.fd_fdstat_get(handle, &statbuf);
3161 if (err != 0) {3161 if (err != .SUCCESS) {
3162 // errno = err;3162 // errno = err;
3163 return false;3163 return false;
3164 }3164 }
lib/std/os/test.zig+8
...@@ -1065,3 +1065,11 @@ test "timerfd" {...@@ -1065,3 +1065,11 @@ test "timerfd" {
1065 try os.timerfd_settime(tfd, 0, &sit, null);1065 try os.timerfd_settime(tfd, 0, &sit, null);
1066 try expectEqual(try os.poll(&fds, 5), 0);1066 try expectEqual(try os.poll(&fds, 5), 0);
1067}1067}
1068
1069test "isatty" {
1070 var tmp = tmpDir(.{});
1071 defer tmp.cleanup();
1072
1073 var file = try tmp.dir.createFile("foo", .{});
1074 try expectEqual(os.isatty(file.handle), false);
1075}