From f70177e76e605ec6e6cd5b938fa77ade5d380e87 Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Mon, 22 Jan 1996 00:02:33 +0000 Subject: Reviewed by: julian and (hsu?) Submitted by: John Birrel(L?) changes for threadsafe operations --- lib/libc/gen/isatty.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/libc/gen/isatty.c') diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c index f6bb04b86316..c8356c710342 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 #include +#ifdef _THREAD_SAFE +#include +#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); } -- cgit v1.2.3