summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/ttyname.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-09-22 17:01:28 +0000
committerpeter <peter@FreeBSD.org>1995-09-22 17:01:28 +0000
commit5d32187f535bda096b77e3ac34a4f15ddf4aa3bc (patch)
treecfc411f7822317e687fe7b7d7dfb5c5d3b06dfaf /lib/libc/gen/ttyname.c
parentd6ac54a0db32a8b6debbcfe209a1c92ffbdbf652 (diff)
downloadFreeBSD-src-5d32187f535bda096b77e3ac34a4f15ddf4aa3bc.zip
FreeBSD-src-5d32187f535bda096b77e3ac34a4f15ddf4aa3bc.tar.gz
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 <cmf@netins.net>
Diffstat (limited to 'lib/libc/gen/ttyname.c')
-rw-r--r--lib/libc/gen/ttyname.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c
index 2f47bd6..f024f52 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 <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
-#include <sgtty.h>
+#include <termios.h>
#include <db.h>
#include <string.h>
#include <paths.h>
@@ -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))
OpenPOWER on IntegriCloud