Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ttyname(3C)

CTERMID(3S)  —  UNIX 3.0

NAME

ctermid − generate file name for terminal

SYNOPSIS

#include <stdio.h>

char ∗ctermid(s)
char ∗s;

DESCRIPTION

Ctermid generates a string that refers to the controlling terminal for the current process when used as a file name. 

If (int)s is zero, 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. If (int)s is non-zero, then s is assumed to point to a character array of at least L_ctermid elements; the string is placed in this array and the value of s is returned.  The manifest constant L_ctermid is defined in <stdio.h>. 

NOTES

The difference between ctermid and ttyname(3C) 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 magic string (/dev/tty) that will refer to the terminal if used as a file name.  Thus ttyname is useless unless the process already has at least one file open to a terminal. 

SEE ALSO

ttyname(3C). 

May 16, 1980

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026