xref: /freebsd/lib/libc/gen/ctermid.3 (revision dc36d6f9bb1753f3808552f3afd30eda9a7b206a)
1.\" Copyright (c) 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd October 1, 2011
29.Dt CTERMID 3
30.Os
31.Sh NAME
32.Nm ctermid
33.Nd generate terminal pathname
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In stdio.h
38.Ft char *
39.Fn ctermid "char *buf"
40.Ft char *
41.Fn ctermid_r "char *buf"
42.Sh DESCRIPTION
43The
44.Fn ctermid
45function generates a string, that, when used as a pathname, refers to
46the current controlling terminal of the calling process.
47.Pp
48If
49.Fa buf
50is the
51.Dv NULL
52pointer, a pointer to a static area is returned.
53Otherwise, the pathname is copied into the memory referenced by
54.Fa buf .
55The argument
56.Fa buf
57is assumed to be at least
58.Dv L_ctermid
59(as defined in the include
60file
61.In stdio.h )
62bytes long.
63.Pp
64The
65.Fn ctermid_r
66function
67provides the same functionality as
68.Fn ctermid
69except that if
70.Fa buf
71is a
72.Dv NULL
73pointer,
74.Dv NULL
75is returned.
76.Pp
77If no suitable lookup of the controlling terminal name can be performed,
78this implementation returns
79.Ql /dev/tty .
80.Sh RETURN VALUES
81Upon successful completion, a
82.Pf non- Dv NULL
83pointer is returned.
84Otherwise, a
85.Dv NULL
86pointer is returned and the global variable
87.Va errno
88is set to indicate the error.
89.Sh ERRORS
90The current implementation detects no error conditions.
91.Sh SEE ALSO
92.Xr ttyname 3
93.Sh STANDARDS
94The
95.Fn ctermid
96function conforms to
97.St -p1003.1-88 .
98.Sh BUGS
99By default the
100.Fn ctermid
101function
102writes all information to an internal static object.
103Subsequent calls to
104.Fn ctermid
105will modify the same object.
106