Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

ttyname - find pathname of terminal

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

char *ttyname(int fildes);

Description ttyname() returns a pointer to a string containing a null-terminated pathname of the

terminal associated with file descriptor fildes. The return value may point to a static area that
is overwritten at each call.

The controlling terminal may have the following names:

/dev/term/0000, ..., /dev/term/4096 (for block-mode terminals)

/dev/pts/0, ..., /dev/pts/4096 (for rlogin access)

Return val.

Pointer to a string

if successful.

Null pointer

if an error occurs. errno is set to indicate the error.

Errors

ttyname() will fail if:

EBADF

ENOTTY

fildes is not a valid file descriptor.

fildes does not point to a terminal.

Notes

ttyname() is executed only for POSIX files

ttyname() is not thread-safe. Use the reentrant function ttyname_r() when needed.

See also

isatty(), ttyname_r(), unistd.h.