1ctermid(3C)              Standard C Library Functions              ctermid(3C)
2
3
4

NAME

6       ctermid, ctermid_r - generate path name for controlling terminal
7

SYNOPSIS

9       #include <stdio.h>
10
11       char *ctermid(char *s);
12
13
14       char *ctermid_r(char *s);
15
16

DESCRIPTION

18   ctermid()
19       The  ctermid() function generates the path name of the controlling ter‐
20       minal for the current process and stores it in a string.
21
22
23       If s is a null pointer, the string is stored in an internal static area
24       whose  address  is  returned  and whose contents are overwritten at the
25       next call to ctermid(). Otherwise, s is assumed to point to a character
26       array  of  at least L_ctermid elements. The path name is placed in this
27       array and the value of s is returned. The constant L_ctermid is defined
28       in the header <stdio.h>.
29
30   ctermid_r()
31       The  ctermid_r()  function  behaves  as ctermid() except that if s is a
32       null pointer, the function returns NULL.
33

USAGE

35       The difference between ctermid() and ttyname(3C) is that ttyname() must
36       be passed a file descriptor and returns the actual name of the terminal
37       associated with that file descriptor, while ctermid() returns a  string
38       (/dev/tty)  that will refer to the terminal if used as a file name. The
39       ttyname() function is useful only if the process already has  at  least
40       one file open to a terminal.
41
42
43       The  ctermid()  function  is unsafe in multithreaded applications.  The
44       ctermid_r() function is MT-Safe and should be used instead.
45
46
47       When compiling multithreaded applications, the  _REENTRANT flag must be
48       defined on the compile line.  This flag should be used only with multi‐
49       threaded applications.
50

ATTRIBUTES

52       See attributes(5) for descriptions of the following attributes:
53
54
55
56
57       ┌─────────────────────────────┬─────────────────────────────┐
58       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
59       ├─────────────────────────────┼─────────────────────────────┤
60       │Interface Stability          │ctermid() is Standard        │
61       ├─────────────────────────────┼─────────────────────────────┤
62       │MT-Level                     │ctermid() is Unsafe;  cter‐  
63       │                             │mid_r() is MT-Safe           │
64       └─────────────────────────────┴─────────────────────────────┘
65

SEE ALSO

67       ttyname(3C), attributes(5)
68
69
70
71SunOS 5.11                        25 Jul 2000                      ctermid(3C)
Impressum