![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Get a fully qualified pathname for a file
#include <unistd.h> char *ttyname( int fildes );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
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, or NULL if an error occurred (errno is set).
/*
* The following program prints out the name
* of the terminal associated with stdin.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main( void )
{
if( isatty( 0 ) ) {
printf( "%s\n", ttyname( 0 ) );
} else {
printf( "\n" );
}
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
ctermid(), setsid(), ttyname_r()
![]() |
![]() |
![]() |
![]() |