]> git.saurik.com Git - apple/libc.git/blob - gen/ttyname.3
Libc-763.11.tar.gz
[apple/libc.git] / gen / ttyname.3
1 .\" Copyright (c) 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. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.10 2002/12/18 13:33:02 ru Exp $
34 .\"
35 .Dd June 4, 1993
36 .Dt TTYNAME 3
37 .Os
38 .Sh NAME
39 .Nm isatty ,
40 .Nm ttyname ,
41 .Nm ttyslot
42 .Nd get name of associated terminal (tty) from file descriptor
43 .Sh LIBRARY
44 .Lb libc
45 .Sh SYNOPSIS
46 .In unistd.h
47 .Ft int
48 .Fo isatty
49 .Fa "int fildes"
50 .Fc
51 .Ft char *
52 .Fo ttyname
53 .Fa "int fildes"
54 .Fc
55 .Ft int
56 .Fo ttyslot
57 .Fa void
58 .Fc
59 .Sh DESCRIPTION
60 These functions operate on the system file descriptors for terminal
61 type devices.
62 These descriptors are not related to the standard
63 .Tn I/O
64 .Dv FILE
65 typedef, but refer to the special device files found in
66 .Pa /dev
67 and named
68 .Pa /dev/tty Ns Ar xx
69 and for which an entry exists
70 in the initialization file
71 .Pa /etc/ttys .
72 (See
73 .Xr ttys 5 . )
74 .Pp
75 The
76 .Fn isatty
77 function
78 determines if the file descriptor
79 .Fa fildes
80 refers to a valid
81 terminal type device.
82 .Pp
83 The
84 .Fn ttyname
85 function
86 gets the related device name of
87 a file descriptor for which
88 .Fn isatty
89 is true.
90 .Pp
91 The
92 .Fn ttyslot
93 function
94 fetches the current process' control terminal number from the
95 .Xr ttys 5
96 file entry.
97 .Sh RETURN VALUES
98 The
99 .Fn ttyname
100 function
101 returns the null terminated name if the device is found and
102 .Fn isatty
103 is true; otherwise, a
104 .Dv NULL
105 pointer is returned.
106 .Pp
107 The
108 .Fn ttyslot
109 function returns the unit number of the device file if found;
110 otherwise, the value zero is returned.
111 .Sh FILES
112 .Bl -tag -width /etc/ttys -compact
113 .It Pa /dev/\(**
114 .It Pa /etc/ttys
115 .El
116 .Sh SEE ALSO
117 .Xr ioctl 2 ,
118 .Xr ttys 5
119 .Sh HISTORY
120 A
121 .Fn isatty ,
122 .Fn ttyname ,
123 and
124 .Fn ttyslot
125 function
126 appeared in
127 .At v7 .
128 .Sh BUGS
129 The
130 .Fn ttyname
131 function leaves its result in an internal static object and returns
132 a pointer to that object.
133 Subsequent calls to
134 .Fn ttyname
135 will modify the same object.