DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

ctermid(S)


ctermid -- generate terminal filename

Syntax

cc . . . -lc

#include  <stdio.h>

char *ctermid (s) char *s;

Description

The ctermid function 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 ctermid, 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 constant L_ctermid is defined in the <stdio.h> header file.

Notes

The difference between ctermid and ttyname(S) is that ttyname must be handed a file descriptor and returns the actual name of the terminal associated with that file descriptor, while ctermid returns a string (/dev/tty) that refers 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.

See also

ttyname(S)

Standards conformance

ctermid is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ;
and NIST FIPS 151-1 .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003