NAME
ttyname, ttyname_r, isatty - Gets the name of a terminal
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <unistd.h>
char *ttyname(
int file_descriptor );
int isatty(
int file_descriptor );
int ttyname_r(
int file_descriptor,
char *buffer,
int len );
PARAMETERS
file_descriptor
Specifies an open file descriptor.
buffer Points to a buffer in which the terminal name is
stored.
len Specifies the length of the buffer pointed to by
the buffer parameter.
DESCRIPTION
The ttyname() function gets the name of a terminal. It
returns a pointer to a string containing the null-terminated
pathname of the terminal device associated with the
file_descriptor parameter.
The isatty() function determines if the device associated
with the file_descriptor parameter is a terminal. If so,
the isatty() function returns a value of 1. If the file
descriptor is not associated with a terminal, a value of 0
(zero) is returned.
The ttyname_r() function is the reentrant version of the
ttyname() function. Upon successful completion, the termi-
nal name is stored as a null-terminated string in the buffer
pointed to by the buffer parameter.
NOTES
AES Support Level:
Full use
RETURN VALUES
The ttyname() function returns a pointer to a string which
is static data that is overwritten by each call. A null
pointer is returned if the file_descriptor parameter does
not describe a terminal device in the directory /dev.
The isatty() function returns a value of 1 if the specified
file descriptor is associated with a terminal, and 0 (zero)
otherwise.
The ttyname_r() function returns 0 (zero) if successful.
Otherwise, -1 is returned.
ERRORS
If the ttyname_r() function fails, errno may be set to the
following value:
[EINVAL] The buffer parameter is a null pointer or the len
parameter was too short to store the string.
[ENOENT] The file_descriptior could not be found.
If the isatty() function fails, errno may be set to the fol-
lowing value:
[ENOTTY] The file associated with filedes is not a termi-
nal.
RELATED INFORMATION
Functions: ttyslot(3)
Acknowledgement and Disclaimer