Browse Source

Have isatty call ioctl directly rather than tcgetattr; especially since any
program using stdio will call isatty during initialization.

Manuel Novoa III 24 years ago
parent
commit
13793a7b4d
1 changed files with 9 additions and 2 deletions
  1. 9 2
      libc/termios/termios.c

+ 9 - 2
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