]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
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 | .\" | |
5b2abdfb | 32 | .\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 |
9385eb3d | 33 | .\" $FreeBSD: src/lib/libc/gen/ttyname.3,v 1.10 2002/12/18 13:33:02 ru Exp $ |
e9ce8d39 | 34 | .\" |
5b2abdfb A |
35 | .Dd June 4, 1993 |
36 | .Dt TTYNAME 3 | |
e9ce8d39 A |
37 | .Os |
38 | .Sh NAME | |
5b2abdfb | 39 | .Nm isatty , |
ad3c9f2a | 40 | .Nm ttyname , |
5b2abdfb A |
41 | .Nm ttyslot |
42 | .Nd get name of associated terminal (tty) from file descriptor | |
e9ce8d39 A |
43 | .Sh LIBRARY |
44 | .Lb libc | |
45 | .Sh SYNOPSIS | |
5b2abdfb | 46 | .In unistd.h |
e9ce8d39 | 47 | .Ft int |
ad3c9f2a A |
48 | .Fo isatty |
49 | .Fa "int fildes" | |
50 | .Fc | |
51 | .Ft char * | |
52 | .Fo ttyname | |
53 | .Fa "int fildes" | |
54 | .Fc | |
5b2abdfb | 55 | .Ft int |
ad3c9f2a A |
56 | .Fo ttyslot |
57 | .Fa void | |
58 | .Fc | |
e9ce8d39 | 59 | .Sh DESCRIPTION |
5b2abdfb A |
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 | |
9385eb3d | 68 | .Pa /dev/tty Ns Ar xx |
5b2abdfb A |
69 | and for which an entry exists |
70 | in the initialization file | |
71 | .Pa /etc/ttys . | |
72 | (See | |
73 | .Xr ttys 5 . ) | |
74 | .Pp | |
e9ce8d39 | 75 | The |
5b2abdfb A |
76 | .Fn isatty |
77 | function | |
78 | determines if the file descriptor | |
ad3c9f2a | 79 | .Fa fildes |
5b2abdfb A |
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 | |
ad3c9f2a | 89 | is true. |
5b2abdfb | 90 | .Pp |
e9ce8d39 | 91 | The |
5b2abdfb A |
92 | .Fn ttyslot |
93 | function | |
94 | fetches the current process' control terminal number from the | |
95 | .Xr ttys 5 | |
96 | file entry. | |
e9ce8d39 | 97 | .Sh RETURN VALUES |
5b2abdfb A |
98 | The |
99 | .Fn ttyname | |
100 | function | |
101 | returns the null terminated name if the device is found and | |
102 | .Fn isatty | |
ad3c9f2a | 103 | is true; otherwise, a |
5b2abdfb A |
104 | .Dv NULL |
105 | pointer is returned. | |
106 | .Pp | |
107 | The | |
108 | .Fn ttyslot | |
ad3c9f2a A |
109 | function returns the unit number of the device file if found; |
110 | otherwise, the value zero is returned. | |
5b2abdfb A |
111 | .Sh FILES |
112 | .Bl -tag -width /etc/ttys -compact | |
113 | .It Pa /dev/\(** | |
114 | .It Pa /etc/ttys | |
115 | .El | |
e9ce8d39 | 116 | .Sh SEE ALSO |
5b2abdfb A |
117 | .Xr ioctl 2 , |
118 | .Xr ttys 5 | |
e9ce8d39 | 119 | .Sh HISTORY |
5b2abdfb A |
120 | A |
121 | .Fn isatty , | |
122 | .Fn ttyname , | |
123 | and | |
124 | .Fn ttyslot | |
125 | function | |
126 | appeared in | |
127 | .At v7 . | |
128 | .Sh BUGS | |
e9ce8d39 | 129 | The |
5b2abdfb A |
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. |