CTERMID(S) XENIX System V CTERMID(S)
Name
ctermid - Generates a filename for a terminal.
Syntax
#include <stdio.h>
char *ctermid(s)
char *s;
Description
ctermid returns a pointer to a string that, when used as a
filename, refers to the controlling terminal of the calling
process.
If (int)s is zero, the string is stored in an internal
static area, the contents of which are overwritten at the
next call to ctermid, and the address of which is returned.
If (int)s is nonzero, then s is assumed to point to a
character array of at least L_ctermid elements; the string
is placed in this array and the value of s is returned. The
manifest constant L_ctermid is defined in <stdio.h>.
Notes
The difference between ctermid and ttyname(S) is that
ttyname must be given a file descriptor and it returns the
actual name of the terminal associated with that file
descriptor, while ctermid returns a magic string (/dev/tty)
that will refer to the terminal if used as a filename. Thus
ttyname is useless unless the process already has at least
one file open to a terminal.
See Also
ttyname(S)
Page 1 (printed 8/7/87)