summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c/ctermid.3c
blob: 4fec552f59309a5686048db28e29a3b1cf869889 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'\" te
.\"  Copyright 1989 AT&T  Copyright (c) 2000, Sun Microsystems, Inc.  All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH CTERMID 3C "Jul 25, 2000"
.SH NAME
ctermid, ctermid_r \- generate path name for controlling terminal
.SH SYNOPSIS
.LP
.nf
#include <stdio.h>

\fBchar *\fR\fBctermid\fR(\fBchar *\fR\fIs\fR);
.fi

.LP
.nf
\fBchar *\fR\fBctermid_r\fR(\fBchar *\fR\fIs\fR);
.fi

.SH DESCRIPTION
.SS "\fBctermid()\fR"
.sp
.LP
The \fBctermid()\fR function generates the path name of the controlling
terminal for the current process and stores it in a string.
.sp
.LP
If \fIs\fR is a null pointer, the string is stored in an internal static area
whose address is returned and whose contents are overwritten at the next call
to \fBctermid()\fR. Otherwise, \fIs\fR is assumed to point to a character array
of at least \fBL_ctermid\fR elements. The path name is placed in this array and
the value of \fIs\fR is returned. The constant \fBL_ctermid\fR is defined in
the header \fB<stdio.h>\fR\&.
.SS "\fBctermid_r()\fR"
.sp
.LP
The \fBctermid_r()\fR function behaves as \fBctermid()\fR except that if
\fIs\fR is a null pointer, the function returns \fINULL\fR.
.SH USAGE
.sp
.LP
The difference between \fBctermid()\fR and \fBttyname\fR(3C) is that
\fBttyname()\fR must be passed a file descriptor and returns the actual name of
the terminal associated with that file descriptor, while \fBctermid()\fR
returns a string (\fB/dev/tty\fR) that will refer to the terminal if used as a
file name. The \fBttyname()\fR function is useful only if the process already
has at least one file open to a terminal.
.sp
.LP
The \fBctermid()\fR function is unsafe in multithreaded applications.  The
\fBctermid_r()\fR function is MT-Safe and should be used instead.
.sp
.LP
When compiling multithreaded applications, the  \fB_REENTRANT\fR flag must be
defined on the compile line.  This flag should be used only with multithreaded
applications.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	\fBctermid()\fR is Standard
_
MT-Level	T{
\fBctermid()\fR is Unsafe; \fBctermid_r()\fR is MT-Safe
T}
.TE

.SH SEE ALSO
.sp
.LP
\fBttyname\fR(3C), \fBattributes\fR(5)