ctermid() — generate file name for terminal
char *ctermid(char *s);
generates a string that, when used as a pathname,
refers to the controlling terminal for the current process.
pointer, the string is stored in an internal static area,
the contents of which are overwritten at the next call to
and the address of which is returned.
is assumed to point to a character array of at least
elements; the path name is placed in this array and the value of
is defined in the
If the process has no controlling terminal,
the pathname for the controlling terminal cannot be determined,
or some other error occurs,
returns an empty string.
For multi-thread applications, if
pointer, the operation is not performed and a
pointer is returned.
The difference between
must be handed a file descriptor
and returns the actual name of the terminal
associated with that file descriptor, while
returns a string
that refers to the terminal if used as a file name.
is useful only if the process already has at least one file open
to a terminal.
ctermid(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1