author | Rich Felker <dalias@aerifal.cx> | 2024年08月20日 12:34:50 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2024年08月20日 12:45:38 -0400 |
commit | c94a0c16f08894ce3be6dafb0fe80baa77a6ff2a (patch) | |
tree | 380614156d998145f3d83d5daf55619e6a4e6f2e /src | |
parent | ee18e584bfe2c694fdd27bd1251ac5b247f864d5 (diff) | |
download | musl-c94a0c16f08894ce3be6dafb0fe80baa77a6ff2a.tar.gz |
-rw-r--r-- | src/unistd/isatty.c | 6 |
diff --git a/src/unistd/isatty.c b/src/unistd/isatty.c index 75a9c186..21222eda 100644 --- a/src/unistd/isatty.c +++ b/src/unistd/isatty.c @@ -6,8 +6,6 @@ int isatty(int fd) { struct winsize wsz; - unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz); - if (r == 0) return 1; - if (errno != EBADF) errno = ENOTTY; - return 0; + /* +1 converts from error status (0/-1) to boolean (1/0) */ + return syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz) + 1; } |