Generate the path name of the current controlling terminal
#include <stdio.h> char * ctermid( char * s );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The ctermid() function generates a string that contains the path name of the current controlling terminal for the calling process.
A pointer to the path name of the controlling terminal, or a pointer to a null string if the function can't locate the controlling terminal.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
printf( "Controlling terminal is %s\n", ctermid( NULL ) );
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Read the Caveats |
The ctermid() function isn't thread-safe if the s argument is NULL.