diff options
author | 1998-11-20 11:18:22 +0000 | |
---|---|---|
committer | 1998-11-20 11:18:22 +0000 | |
commit | 92efb7350713770eeac379dc990eaecbee107aa1 (patch) | |
tree | 9e7a54e9f5f807b6269323fc5be9480298ad6de5 /lib/libc/gen/isatty.c | |
parent | Move atomic_lock code from asm to C with inline asm; (diff) | |
download | wireguard-openbsd-92efb7350713770eeac379dc990eaecbee107aa1.tar.xz wireguard-openbsd-92efb7350713770eeac379dc990eaecbee107aa1.zip |
Add thread-safety to libc, so that libc_r will build (on i386 at least).
All POSIX libc api now there (to P1003.1c/D10)
(more md stuff is needed for other libc/arch/*)
(setlogin is no longer a special syscall)
Add -pthread option to gcc (that makes it use -lc_r and -D_POSIX_THREADS).
Doc some re-entrant routines
Add libc_r to intro(3)
dig() uses some libc srcs and an extra -I was needed there.
Add more md stuff to libc_r.
Update includes for the pthreads api
Update libc_r TODO
Diffstat (limited to 'lib/libc/gen/isatty.c')
-rw-r--r-- | lib/libc/gen/isatty.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c index d4dc9ad6cf6..f32cf3eaeb5 100644 --- a/lib/libc/gen/isatty.c +++ b/lib/libc/gen/isatty.c @@ -32,17 +32,25 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: isatty.c,v 1.2 1996/08/19 08:24:32 tholo Exp $"; +static char rcsid[] = "$OpenBSD: isatty.c,v 1.3 1998/11/20 11:18:39 d Exp $"; #endif /* LIBC_SCCS and not lint */ #include <termios.h> #include <unistd.h> +#include "thread_private.h" int isatty(fd) int fd; { + int retval; struct termios t; - return(tcgetattr(fd, &t) != -1); + if (_FD_LOCK(fd, FD_READ, NULL) == 0) { + retval = (tcgetattr(fd, &t) != -1); + _FD_UNLOCK(fd, FD_READ); + } else { + retval = 0; + } + return(retval); } |