ttyname(3C)
NAME
ttyname(), ttyname_r(), isatty() − find name of a terminal
SYNOPSIS
#include <unistd.h>
char *ttyname(int fildes);
int ttyname_r(int fildes, char *buffer, int buflen);
int isatty(int fildes);
DESCRIPTION
ttyname() returns a pointer to a string containing the null-terminated path name of the terminal device associated with file descriptor fildes.
isatty() returns 1 if fildes is associated with a terminal device, 0 otherwise.
Reentrant Interfaces
ttyname_r() returns the result string in the supplied buffer. A buffer length of 64 is recommended. If an error is detected or the buffer is of insufficient length, -1 is returned. If the operation is successful, 0 is returned.
RETURN VALUE
ttyname() returns a NULL pointer if fildes does not describe a terminal device in directory /dev.
ERRORS
isatty() and ttyname() fail if any of the following conditions are encountered:
[EBADF] The fildes argument is invalid.
[ENOTTY] An inappropriate I/O control operation has been attempted.
WARNINGS
The return value for ttyname() points to static data whose content is overwritten by each call. For streams ptys, ttyname() and isatty() do not consider master ptys to be tty devices. It should also be noted that ttyname() returns a pointer to the master pty name for all master pty devices. This is a result of device files being linked together.
ttyname() is unsafe for multi-thread applications. ttyname_r() is MT-Safe and should be used instead.
Users of ttyname_r() should also note that the prototype of this function will change in the next release for conformance with the new POSIX Threads standard.
FILES
/dev/*
/dev/pty/*
STANDARDS CONFORMANCE
ttyname(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
isatty(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
Hewlett-Packard Company — HP-UX Release 10.20: July 1996