summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/isatty.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen/isatty.c')
-rw-r--r--lib/libc/gen/isatty.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c
index f6bb04b..c8356c7 100644
--- a/lib/libc/gen/isatty.c
+++ b/lib/libc/gen/isatty.c
@@ -37,12 +37,27 @@ static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93";
#include <termios.h>
#include <unistd.h>
+#ifdef _THREAD_SAFE
+#include <pthread.h>
+#include "pthread_private.h"
+#endif
int
isatty(fd)
int fd;
{
+ int retval;
struct termios t;
- return(tcgetattr(fd, &t) != -1);
+#ifdef _THREAD_SAFE
+ if (_thread_fd_lock(fd, FD_READ, NULL,__FILE__,__LINE__) == 0) {
+#endif
+ retval = (tcgetattr(fd, &t) != -1);
+#ifdef _THREAD_SAFE
+ _thread_fd_unlock(fd, FD_READ);
+ } else {
+ retval = 0;
+ }
+#endif
+ return(retval);
}
OpenPOWER on IntegriCloud