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

This commit is contained in:
Takeshi Yoneda 2022-12-11 17:44:38 +09:00 committed by GitHub
parent cffbb32d31
commit 78ea270cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -3158,7 +3158,7 @@ pub fn isatty(handle: fd_t) bool {
if (builtin.os.tag == .wasi) {
var statbuf: fdstat_t = undefined;
const err = system.fd_fdstat_get(handle, &statbuf);
if (err != 0) {
if (err != .SUCCESS) {
// errno = err;
return false;
}

View File

@ -1065,3 +1065,11 @@ test "timerfd" {
try os.timerfd_settime(tfd, 0, &sit, null);
try expectEqual(try os.poll(&fds, 5), 0);
}
test "isatty" {
var tmp = tmpDir(.{});
defer tmp.cleanup();
var file = try tmp.dir.createFile("foo", .{});
try expectEqual(os.isatty(file.handle), false);
}