COHERENT manpages

This page displays the COHERENT manpage for ctermid() [Name the terminal device that controls the current process].

List of available manpages
Index


ctermid() -- General Function (libc)

Name the terminal device that controls the current process
#include <stdio.h>
char *ctermid (path_name)
char *path_name;

The general  function ctermid() returns the full path  name of the terminal
device  that controls  the current  process.  It  does for  the controlling
terminal what the function ttyname() does for a general file descriptor.

path_name points  to a block of  memory into which ctermid()  can write the
name of the contolling terminal.  It must point to at least L_ctermid bytes
of available memory.  If path_name  is NULL, ctermid() writes the name into
a statically  allocated buffer that may be  overwritten by subsequent calls
to ctermid().

If all goes well, ctermid() returns  the address where it wrote the name of
the controlling terminal.  If an error  occurs -- for example, it could not
discover  the name  of  the controlling  terminal  -- it  returns an  empty
string.

See Also

libc
POSIX Standard 1003.1, §4.7.1

Notes

In almost every instance, ctermid() returns the string ``/dev/tty''.  Under
COHERENT, the  name of the controlling terminal for  the current process is
/dev/tty.  Because  some  operating  systems  do  not  follow  this  common
practice, POSIX Standard provides  ctermid() as a portable means of getting
the controlling terminal's name.