]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/isatty.c.patch
Libc-498.1.5.tar.gz
[apple/libc.git] / gen / FreeBSD / isatty.c.patch
1 --- isatty.c.orig 2003-05-20 15:21:02.000000000 -0700
2 +++ isatty.c 2005-06-02 13:46:32.000000000 -0700
3 @@ -39,14 +39,21 @@
4
5 #include <termios.h>
6 #include <unistd.h>
7 +#include <sys/filio.h>
8 +#include <sys/conf.h>
9 +#include <errno.h>
10
11 int
12 isatty(fd)
13 int fd;
14 {
15 - int retval;
16 + int retval, type;
17 struct termios t;
18
19 - retval = (tcgetattr(fd, &t) != -1);
20 + if(ioctl(fd, FIODTYPE, &type) != -1) {
21 + if((retval = (type == D_TTY)) == 0)
22 + errno = ENOTTY;
23 + } else
24 + retval = (tcgetattr(fd, &t) != -1);
25 return(retval);
26 }