TTYNAME(3) BSD TTYNAME(3)
NAME
ttyname, ttyname_r, isatty, ttyslot - find name of a terminal
SYNOPSIS
char *ttyname(filedes)
int ttyname_r (fildes, buffer, len)
int fildes;
char *buffer;
int len;
isatty(filedes)
ttyslot()
DESCRIPTION
ttyname returns a pointer to the null terminated pathname of the terminal
device associated with file descriptor filedes (this is a system file
descriptor and has nothing to do with the standard I/O FILE typedef).
ttyname_r function is the reentrant version of the ttyname function.
isatty returns 1 if filedes is associated with a terminal device, 0
otherwise.
ttyslot returns the index of the current user's entry in the /etc/utmp
file.
FILES
/dev/*
/etc/utmp
NOTES
Under some implementations, ttyslot returns the number of the entry in
the ttys(5) file for the control terminal of the current process.
SEE ALSO
ioctl(2), ttys(5), utmp(5).
DIAGNOSTICS
ttyname returns a null pointer (0) if filedes does not describe a
terminal device in directory /dev.
The ttyname_r function returns 0 (zero) if successful. Otherwise, -1 is
returned.
ttyslot returns 0 if /etc/utmp is inaccessible or if it cannot determine
the control terminal.
BUGS
The return value points to static data whose content is overwritten by
each call.