summaryrefslogtreecommitdiff
path: root/libc/termios/termios.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-02-19 11:21:34 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-02-19 11:21:34 +0000
commit13793a7b4d7aa4c36f42c46643c0457a05071ba5 (patch)
treee811ef3c622fbe3fa077781238cfce415e32c085 /libc/termios/termios.c
parent84fb6c9e25ba15319b817ecf2a46e2cb83d64d13 (diff)
Have isatty call ioctl directly rather than tcgetattr; especially since any
program using stdio will call isatty during initialization.
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