ctermid
Purpose
Generates a file name for terminal.
Library
Standard I/O Library (libc.a)
Syntax
#include <stdio.h>
char *ctermid (s)
char *s;
Description
The ctermid subroutine generates the path name of the
controlling terminal for the current process and stores
it in a string.
If the s parameter is a NULL pointer, the string is
stored in an internal static area and the address is
returned. The next call to ctermid overwrites the con-
tents of the internal static area.
If the s parameter is not a NULL pointer, it points to a
character array of at least L_ctermid elements as defined
in the stdio.h header file. The path name is placed in
this array and the value of s is returned.
The difference between the ctermid and ttyname subrou-
tines is that ttyname must be handed a file descriptor
and returns the actual name of the terminal associated
with that file descriptor, while ctermid returns a string
(/dev/tty) that refers to the terminal if used as a file
name. Thus ttyname is useful only if the process already
has at least one file open to a terminal.
Related Information
In this book: "ttyname, isatty."