summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/isatty.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1996-01-22 00:02:33 +0000
committerjulian <julian@FreeBSD.org>1996-01-22 00:02:33 +0000
commit619b731f5bb5e09dcf1eaf1fbd96383ca64398fd (patch)
treea89c7f50ec371cef4418259b9dccdd31ebb2f61f /lib/libc/gen/isatty.c
parent663b14fb2f3198fb0bfb62ae16b6b56c2a4dd055 (diff)
downloadFreeBSD-src-619b731f5bb5e09dcf1eaf1fbd96383ca64398fd.zip
FreeBSD-src-619b731f5bb5e09dcf1eaf1fbd96383ca64398fd.tar.gz
Reviewed by: julian and (hsu?)
Submitted by: John Birrel(L?) changes for threadsafe operations
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