Gets the name of a terminal or determines if the device is a terminal.
Standard C Library (libc.a)
#include <unistd.h>
char *ttyname( FileDescriptor)
int FileDescriptor;
int isatty(FileDescriptor) int FileDescriptor;
The ttyname subroutine gets the path name of a terminal.
The isatty subroutine determines if the file descriptor specified by the FileDescriptor parameter is associated with a terminal.
The isatty subroutine does not necessarily indicate that a person is available for interaction, since nonterminal devices may be connected to the communications line.
FileDescriptor | Specifies an open file descriptor. |
The ttyname subroutine returns a pointer to a string containing the null-terminated path name of the terminal device associated with the file descriptor specified by the FileDescriptor parameter. A null pointer is returned and the errno global variable is set to indicate the error if the file descriptor does not describe a terminal device in the /dev directory.
The return value of the ttyname subroutine may point to static data whose content is overwritten by each call.
If the specified file descriptor is associated with a terminal, the isatty subroutine returns a value of 1. If the file descriptor is not associated with a terminal, a value of 0 is returned and the errno global variable is set to indicate the error.
The ttyname and isatty subroutines are unsuccessful if one of the following is true:
EBADF | The FileDescriptor parameter does not specify a valid file descriptor. |
ENOTTY | The FileDescriptor parameter does not specify a terminal device. |
/dev/* | Terminal device special files. |
The ttyslot (ttyslot Subroutine) subroutine.
The Input and Output Handling Programmer's Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.