Gets the name of a terminal or determines if the device is a terminal.
#include <unistd.h>
char *ttyname(FileDescriptor) int FileDescriptor;
int isatty(FileDescriptor) int FileDescriptor;
Attention: Do not use the ttyname subroutine in a multithreaded environment.
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. |
These subroutines are part of Base Operating System (BOS) Runtime.
/dev/* | Terminal device special files. |
The ttyslot subroutine.
The Input and Output Handling Programmer's Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.