get a fully qualified pathname for a file
#include <unistd.h> char *ttyname( int fildes );
The ttyname() function returns a pointer to a static buffer that contains a fully qualified pathname associated with the file associated with fildes.
A pointer to the pathname for fildes. If the function fails, it returns NULL and sets errno.
/* * 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" ); } }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
ctermid(), errno, qnx_spawn(), setsid(), tcsetct()