aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2008-11-18 22:55:06 +0000
committerJeff Johnston <jjohnstn@redhat.com>2008-11-18 22:55:06 +0000
commit1f9aa7a3f0e7c8bd5b5ec77718ad1dff031fe97c (patch)
treefd7f96db7f506fd030f76ab7b6755e7a4bfb905f
parentefb00eb5dac6ead2355fb78c93a22bed6ed7379f (diff)
downloadnewlib-1f9aa7a3f0e7c8bd5b5ec77718ad1dff031fe97c.zip
newlib-1f9aa7a3f0e7c8bd5b5ec77718ad1dff031fe97c.tar.gz
newlib-1f9aa7a3f0e7c8bd5b5ec77718ad1dff031fe97c.tar.bz2
2008-11-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* libc/unix/ttyname.c: Use isatty() instead of tcgetattr().
-rw-r--r--newlib/ChangeLog4
-rw-r--r--newlib/libc/unix/ttyname.c6
2 files changed, 6 insertions, 4 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index dcb7c6e..e281c43 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-18 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * libc/unix/ttyname.c: Use isatty() instead of tcgetattr().
+
2008-11-18 Jeff Johnston <jjohnstn@redhat.com>
* 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 fec8fc4..7e0fec8 100644
--- a/newlib/libc/unix/ttyname.c
+++ b/newlib/libc/unix/ttyname.c
@@ -32,7 +32,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
-#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <paths.h>
@@ -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))