diff --git a/newlib/ChangeLog b/newlib/ChangeLog index dcb7c6e27..e281c432b 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,7 @@ +2008-11-18 Joel Sherrill + + * libc/unix/ttyname.c: Use isatty() instead of tcgetattr(). + 2008-11-18 Jeff Johnston * libc/unix/basename.c: Add !_NO_BASENAME flag check so code can be diff --git a/newlib/libc/unix/ttyname.c b/newlib/libc/unix/ttyname.c index fec8fc410..7e0fec89c 100644 --- a/newlib/libc/unix/ttyname.c +++ b/newlib/libc/unix/ttyname.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -51,15 +50,14 @@ _DEFUN( ttyname_r,(fd, name, namesize), size_t namesize) { struct stat sb; - struct termios tty; struct dirent *dirp; DIR *dp; struct stat dsb; char buf[sizeof(ttyname_buf)]; /* Must be a terminal. */ - if (tcgetattr (fd, &tty) < 0) - return errno; /* Can be EBADF or ENOTTY */ + if (!isatty(fd)) + return ENOTTY; /* Must be a character device. */ if (fstat (fd, &sb) || !S_ISCHR (sb.st_mode))