OSDN Git Service

Sometimes (often) the kernel will return things other then -1.
authorEric Andersen <andersen@codepoet.org>
Tue, 29 May 2001 17:43:46 +0000 (17:43 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 29 May 2001 17:43:46 +0000 (17:43 -0000)
Deal with it.
 -Erik

libc/termios/termios.c

index d6cd124..e0c3743 100644 (file)
 
 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