isatty.c (1574) | isatty.c (13545) |
---|---|
1/* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <termios.h> 39#include <unistd.h> | 1/* 2 * Copyright (c) 1988, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93"; 36#endif /* LIBC_SCCS and not lint */ 37 38#include <termios.h> 39#include <unistd.h> |
40#ifdef _THREAD_SAFE 41#include <pthread.h> 42#include "pthread_private.h" 43#endif |
|
40 41int 42isatty(fd) 43 int fd; 44{ | 44 45int 46isatty(fd) 47 int fd; 48{ |
49 int retval; |
|
45 struct termios t; 46 | 50 struct termios t; 51 |
47 return(tcgetattr(fd, &t) != -1); | 52#ifdef _THREAD_SAFE 53 if (_thread_fd_lock(fd, FD_READ, NULL,__FILE__,__LINE__) == 0) { 54#endif 55 retval = (tcgetattr(fd, &t) != -1); 56#ifdef _THREAD_SAFE 57 _thread_fd_unlock(fd, FD_READ); 58 } else { 59 retval = 0; 60 } 61#endif 62 return(retval); |
48} | 63} |