unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (SunOS-4.1.3)
Page:
Section:
Apropos / Subsearch:
optional field

CTERMID(3V)                                                        CTERMID(3V)



NAME
       ctermid - generate filename for terminal

SYNOPSIS
       char *ctermid (s)
       char *s;

DESCRIPTION
       ctermid()  generates  the  pathname 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 L_ctermid elements; the path
       name is placed in this array and the value of s is returned.  The  con-
       stant L_ctermid is defined in <&lt;stdio.h>&gt; header file.

       ctermid()  returns  a  pointer  to a null string if it fails, or if the
       pathname that would refer to the controlling terminal cannot be  deter-
       mined.

SEE ALSO
       ttyname(3V)

NOTES
       The difference between ctermid() and ttyname(3V) is that ttyname() must
       be passed a file descriptor and returns the actual name of the terminal
       associated  with that file descriptor, while ctermid() returns a string
       (/dev/tty) that will refer 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.  ctermid() is useful largely for  making  code
       portable  to  (non-UNIX) systems where the current terminal is referred
       to by a name other than /dev/tty.



                                5 October 1989                     CTERMID(3V)