]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/isatty.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / gen / FreeBSD / isatty.c.patch
CommitLineData
1f2f436a
A
1--- isatty.c.orig 2009-11-07 14:51:38.000000000 -0800
2+++ isatty.c 2009-11-07 14:51:40.000000000 -0800
3@@ -35,14 +35,22 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/isa
9385eb3d
A
4
5 #include <termios.h>
6 #include <unistd.h>
7+#include <sys/filio.h>
8+#include <sys/conf.h>
34e8f829 9+#include <sys/ioctl.h>
224c7076 10+#include <errno.h>
9385eb3d
A
11
12 int
13 isatty(fd)
14 int fd;
15 {
16- int retval;
17+ int retval, type;
18 struct termios t;
19
20- retval = (tcgetattr(fd, &t) != -1);
224c7076
A
21+ if(ioctl(fd, FIODTYPE, &type) != -1) {
22+ if((retval = (type == D_TTY)) == 0)
23+ errno = ENOTTY;
24+ } else
9385eb3d
A
25+ retval = (tcgetattr(fd, &t) != -1);
26 return(retval);
27 }