ctermid(3S) ctermid(3S)
NAME
ctermid - generate filename for terminal
SYNOPSIS
#include <stdio.h>
char *ctermid(char *s);
DESCRIPTION
ctermid() generates the path name of the controlling terminal for the
current process, and stores it in a string.
If s is a null pointer, the string is stored in an internal static
area, the contents of which are overwritten at the next call to cter-
mid(), and the address of which is returned. Otherwise, s is assumed
to point to a character array of at least Lctermid elements; the path
name is placed in this array and the value of s is returned. The con-
stant Lctermid defined in the stdio.h header file.
NOTES
The difference between ctermid() and ttyname(3C) is as follows:
ttyname() expects to receive a file descriptor and returns the actual
name of the terminal associated with that file descriptor, while cter-
mid() returns a string (/dev/tty) that will refer to the terminal if
used as a filename. Thus ttyname() is useful only if the process
already has at least one file open to a terminal.
SEE ALSO
ttyname(3C).
Page 1 Reliant UNIX 5.44 Printed 11/98