[Previous]
[Contents]
[Next]

ctermid()

generate the pathname of the current controlling terminal

Synopsis:

#include <stdio.h>
char *ctermid( char *s );

Description:

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, the pathname is placed in that string. This string should be at least L_ctermid characters long (see <stdio.h>).

Returns:

A pointer to the pathname of the controlling terminal, or a pointer to a null string if the function was unable to locate the controlling terminal,

Examples:

#include <stdio.h>

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

Classification:

POSIX 1003.1

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

Caveats:

If the s parameter is NULL, this function isn't signal-handler-safe or thread-safe.

See also:

setsid(), tcsetct(), ttyname()


[Previous]
[Contents]
[Next]