ttyname(S) 6 January 1993 ttyname(S) Name ttyname, isatty - get name of a terminal Syntax cc . . . -lc #include <stdlib.h> #include <unistd.h> char *ttyname (fildes) int fildes; int isatty (fildes) int fildes; Description The ttyname routine returns a pointer to a string containing the null- terminated pathname of the terminal device associated with file descriptor fildes. The return value may point to static data whose con- tent is overwritten by each call. The isatty routine tests whether fildes, an open file descriptor, is associated with a terminal device. isatty returns 1 if fildes is associ- ated with a terminal device, 0 otherwise with errno set. Files /dev/* Diagnostics On unsuccessful completion ttyname, returns a null pointer if fildes does not describe a terminal device in directory /dev and errno is set. If either isatty or ttyname fail, then errno contains one of: [EBADF] The fildes argument is not a valid file descriptor. [ENOTTY] The fildes argument does not refer to a terminal device. Note The return value points to static data whose content is overwritten by each call. Standards conformance isatty and ttyname are conformant with: AT&T SVID Issue 2; X/Open Portability Guide, Issue 3, 1989; Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2); IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1); and NIST FIPS 151-1.