summaryrefslogtreecommitdiff
path: root/libc/termios/termios.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/termios/termios.c')
-rw-r--r--libc/termios/termios.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libc/termios/termios.c b/libc/termios/termios.c
index 9bfcf1171..a180e1011 100644
--- a/libc/termios/termios.c
+++ b/libc/termios/termios.c
@@ -31,11 +31,18 @@
#ifdef L_isatty
/* Return 1 if FD is a terminal, 0 if not. */
+#include "kernel_termios.h"
+
int isatty(int fd)
{
- struct termios term;
+ struct __kernel_termios k_term;
- return tcgetattr(fd, &term) == 0;
+ /*
+ * When ioctl returns -1 we want to return 0 and
+ * when ioctl returns 0 we want to return 1.
+ * Incrementing is cheaper (size & speed) than a test.
+ */
+ return ioctl(fd, TCGETS, &k_term) + 1;
}
#endif