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_r - find pathname of terminal (thread-safe)

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

int ttyname_r(int fildes, char * name, size_t namesize);

Description  The function ttyname_r() stores the null-terminated pathname of the terminal associated

with file descriptor fildes in the data area pointed to by name. The data area is namesize
characters long and should provide enough storage space for the name and the terminating
null. The maximum length of the terminal name is {TTY_NAME_MAX}.

Return val.

0                       if successful.

Otherwise the error number.

Errors

ttyname_r() fails if:

EBADF

ENOTTY

ERANGE

fildes is not a valid file descriptor.

fildes does not point to a terminal.

the value of namesize is smaller than the length of the string returned including
the terminating null byte.

See also

ttyname(), isatty(), unistd.h.