The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

ttyname, ttyname_r - find pathname of a terminal

 SYNOPSIS



#include <unistd.h>

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

 DESCRIPTION

The ttyname() function 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 static data whose content is overwritten by each call.

The ttyname() interface need not be reentrant.

The ttyname_r() function stores the null-terminated pathname of the terminal associated with the file descriptor fildes in the character array referenced by name. The array is namesize characters long and should have space for the name and the terminating null character. The maximum length of the terminal name is {TTY_NAME_MAX}.

 RETURN VALUE

Upon successful completion, ttyname() returns a pointer to a string. Otherwise, a null pointer is returned and errno is set to indicate the error.

If successful, the ttyname_r() function returns zero. Otherwise, an error number is returned to indicate the error.

 ERRORS

The ttyname() function may fail if:
[EBADF]
The fildes argument is not a valid file descriptor.
[ENOTTY]
The fildes argument does not refer to a terminal device.

The ttyname_r() function may fail if:

[EBADF]
The fildes argument is not a valid file descriptor.
[ENOTTY]
The fildes argument does not refer to a tty.
[ERANGE]
The value of namesize is smaller than the length of the string to be returned including the terminating null character.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

<unistd.h>.

DERIVATION

ttyname() derived from Issue 1 of the SVID.

ttyname_r() derived from the POSIX Threads Extension (1003.1c-1995).


UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]