www.delorie.com/gnu/docs/glibc/libc_588.html   search  
 
Buy the book!


The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

27.7.1 Identifying the Controlling Terminal

You can use the ctermid function to get a file name that you can use to open the controlling terminal. In the GNU library, it returns the same string all the time: "/dev/tty". That is a special "magic" file name that refers to the controlling terminal of the current process (if it has one). To find the name of the specific terminal device, use ttyname; see section 17.1 Identifying Terminals.

The function ctermid is declared in the header file `stdio.h'.

Function: char * ctermid (char *string)
The ctermid function returns a string containing the file name of the controlling terminal for the current process. If string is not a null pointer, it should be an array that can hold at least L_ctermid characters; the string is returned in this array. Otherwise, a pointer to a string in a static area is returned, which might get overwritten on subsequent calls to this function.

An empty string is returned if the file name cannot be determined for any reason. Even if a file name is returned, access to the file it represents is not guaranteed.

Macro: int L_ctermid
The value of this macro is an integer constant expression that represents the size of a string large enough to hold the file name returned by ctermid.

See also the isatty and ttyname functions, in 17.1 Identifying Terminals.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003