Parcourir la source

Sometimes (often) the kernel will return things other then -1.
Deal with it.
-Erik

Eric Andersen il y a 23 ans
Parent
commit
caa78fb3fd
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      libc/termios/termios.c

+ 6 - 7
libc/termios/termios.c

@@ -35,14 +35,13 @@
 
 int isatty(int fd)
 {
-	struct __kernel_termios k_term;
+    struct __kernel_termios k_term;
 
-	/*
-	* 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;
+    /*
+     * When ioctl returns -1 we want to return 0 and
+     * when ioctl returns  0 we want to return 1.
+     */
+    return (ioctl(fd, TCGETS, &k_term)==0)? 1 : 0; 
 }
 #endif