The functions described in this chapter only work on files that
correspond to terminal devices. You can find out whether a file
descriptor is associated with a terminal by using the
Prototypes for both
ttyname are declared in
the header file `unistd.h'.
1if filedes is a file descriptor associated with an open terminal device, and
If a file descriptor is associated with a terminal, you can get its
associated file name using the
ttyname function. See also the
ctermid function, described in section Identifying the Controlling Terminal.
ttynamefunction returns a pointer to a statically-allocated, null-terminated string containing the file name of the terminal file. The value is a null pointer if the file descriptor isn't associated with a terminal, or the file name cannot be determined.
Go to the first, previous, next, last section, table of contents.