From fcc3b6999ed94cae262ffd7d69030907b9904663 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 22 Sep 1995 17:01:28 +0000 Subject: [PATCH] Make ttyname() use posix-style tcgetattr() to check to see that it's running on a tty. (Same as isatty()) The old-style TIOCGETP ioctl wouldn't fly if the kernel didn't have COMPAT_43. Submitted by: Carl Fongheiser --- lib/libc/gen/ttyname.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index 2f47bd66b4c..f024f52e20c 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94"; #include #include #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ ttyname(fd) int fd; { struct stat sb; - struct sgttyb ttyb; + struct termios ttyb; DB *db; DBT data, key; struct { @@ -61,7 +61,7 @@ ttyname(fd) } bkey; /* Must be a terminal. */ - if (ioctl(fd, TIOCGETP, &ttyb) < 0) + if (tcgetattr(fd, &ttyb) < 0) return (NULL); /* Must be a character device. */ if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode))