![]() |
![]() |
![]() |
Generate the pathname of the current controlling terminal
#include <stdio.h> char * ctermid( char * s );
libc
The ctermid() function generates a string that contains the pathname of the current controlling terminal for the calling process.
If the argument s is NULL, the string is built in a static buffer, and a pointer to the buffer is returned.
If the argument s isn't NULL, then the pathname is placed in that string. This string should be at least L_ctermid characters long (see <stdio.h>).
A pointer to the pathname of the controlling terminal; or a pointer to a null string if it's unable to 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() isn't thread-safe if the s argument is NULL.
![]() |
![]() |
![]() |