ctermid()

Generate the path name of the current controlling terminal

Synopsis:

#include <stdio.h>

char * ctermid( char * s );

Arguments:

s
NULL, or a pointer to a buffer in which the function can store the path name of the controlling terminal. This string should be at least L_ctermid characters long (see <stdio.h>).

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The ctermid() function generates a string that contains the path name of the current controlling terminal for the calling process.

Note: If the argument s is NULL, the string is built in a static buffer, and the function returns a pointer to the buffer.

Returns:

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.

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
  printf( "Controlling terminal is %s\n", ctermid( NULL ) );
  return EXIT_SUCCESS;
}

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Read the Caveats

Caveats:

The ctermid() function isn't thread-safe if the s argument is NULL.