]> git.saurik.com Git - apple/libc.git/blame_incremental - gen/FreeBSD/isatty.c.patch
Libc-763.12.tar.gz
[apple/libc.git] / gen / FreeBSD / isatty.c.patch
... / ...
CommitLineData
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
4
5 #include <termios.h>
6 #include <unistd.h>
7+#include <sys/filio.h>
8+#include <sys/conf.h>
9+#include <sys/ioctl.h>
10+#include <errno.h>
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);
21+ if(ioctl(fd, FIODTYPE, &type) != -1) {
22+ if((retval = (type == D_TTY)) == 0)
23+ errno = ENOTTY;
24+ } else
25+ retval = (tcgetattr(fd, &t) != -1);
26 return(retval);
27 }