From 13793a7b4d7aa4c36f42c46643c0457a05071ba5 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Mon, 19 Feb 2001 11:21:34 +0000 Subject: Have isatty call ioctl directly rather than tcgetattr; especially since any program using stdio will call isatty during initialization. --- libc/termios/termios.c | 11 +++++++++-- 1 file 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 -- cgit v1.2.3