[Previous]
[Contents]
[Next]

ttyname()

get a fully qualified pathname for a file

Synopsis:

#include <unistd.h>

char *ttyname( int fildes );

Description:

The ttyname() function returns a pointer to a static buffer that contains a fully qualified pathname associated with the file associated with fildes.

Returns:

A pointer to the pathname for fildes. If the function fails, it returns NULL and sets errno.

Errors:

EBADF
The fildes argument is invalid.
ENOTTY
Not a tty.

Examples:

/*
 * The following program prints the name
 * of the terminal associated with stdin.
 */
#include <stdio.h>
#include <unistd.h>

void main()
{
    if( isatty( 0 ) ) {
        printf( "%s\n", ttyname( 0 ) );
    } else {
        printf( "\n" );
    }
}

Classification:

POSIX 1003.1

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

ctermid(), errno, qnx_spawn(), setsid(), tcsetct()


[Previous]
[Contents]
[Next]