mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-05-04 17:34:21 +02:00
upstream: https://git.musl-libc.org/cgit/musl/commit/src/unistd/isatty.c?id=c94a0c16f08894ce3be6dafb0fe80baa77a6ff2a
15 lines
456 B
Diff
15 lines
456 B
Diff
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;
|
|
}
|