diff options
| author | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
| commit | f70177e76e605ec6e6cd5b938fa77ade5d380e87 (patch) | |
| tree | a89c7f50ec371cef4418259b9dccdd31ebb2f61f /lib/libc/gen/isatty.c | |
| parent | 61de51cad66df0d565233915f856932159d33a4a (diff) | |
Notes
Diffstat (limited to 'lib/libc/gen/isatty.c')
| -rw-r--r-- | lib/libc/gen/isatty.c | 17 |
1 files changed, 16 insertions, 1 deletions
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 <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); } |
