summaryrefslogtreecommitdiff
path: root/lib/libc/gen/isatty.c
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1998-11-20 11:19:02 +0000
committerDavid Leonard <d@cvs.openbsd.org>1998-11-20 11:19:02 +0000
commitf547068f88348f54941dc06da46491f99701933e (patch)
tree8548a6b78719cba1de575b7f49e5f8ac4e6f1683 /lib/libc/gen/isatty.c
parent394c7a9821726b84f284c0c4385b1a9198afa0b0 (diff)
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.c12
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);
}