Commit | Line | Data |
---|---|---|
ae59e04c CL |
1 | .\" Copyright (c) 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
2264871c | 3 | .\" |
ae59e04c CL |
4 | .\" %sccs.include.redist.man% |
5 | .\" | |
6 | .\" @(#)ttyname.3 6.2 (Berkeley) %G% | |
7 | .\" | |
8 | .Dd | |
9 | .Dt TTYNAME 3 | |
10 | .Os | |
11 | .Sh NAME | |
12 | .Nm ttyname , | |
13 | .Nm isatty , | |
14 | .Nm ttyslot | |
15 | .Nd get name of associated terminal (tty) from file descriptor | |
16 | .Sh SYNOPSIS | |
17 | .Fd #include <unistd.h> | |
18 | .Ft char * | |
19 | .Fn ttyname "int fd" | |
20 | .Ft int | |
21 | .Fn isatty "int fd" | |
22 | .Ft int | |
23 | .Fn ttyslot | |
24 | .Sh DESCRIPTION | |
25 | These functions operate on the system file descriptors for terminal | |
26 | type devices. These descriptors are not related to the standard | |
27 | .Tn I/O | |
28 | .Dv FILE | |
29 | typedef, but refer to the special device files found in | |
30 | .Pa /dev | |
31 | and named | |
32 | .Pa /dev/tty Ns Em xx | |
33 | and for which an entry exists | |
34 | in the initialization file | |
35 | .Pa /etc/ttys. | |
36 | (See | |
37 | .Xr ttys 5 . ) | |
38 | .Pp | |
39 | The | |
40 | .Fn isatty | |
41 | function | |
42 | determines if the file descriptor | |
43 | .Fa fd | |
44 | refers to a valid | |
45 | terminal type device. | |
46 | .Pp | |
47 | The | |
48 | .Fn ttyname | |
49 | function | |
50 | gets the related device name of | |
51 | a file descriptor for which | |
52 | .Fn isatty | |
53 | is true | |
54 | .Pp | |
55 | The | |
56 | .Fn ttyslot | |
57 | function | |
58 | fetches the current process' control terminal number from the | |
59 | .Xr ttys 5 | |
60 | file entry. | |
61 | .Sh RETURN VALUES | |
62 | The | |
63 | .Fn ttyname | |
64 | function | |
65 | returns the null terminated name if the device is found and | |
66 | .Fn isatty | |
67 | is true; otherwise | |
68 | a | |
69 | .Dv NULL | |
70 | pointer is returned. | |
71 | .Pp | |
72 | The | |
73 | .Fn ttyslot | |
74 | function | |
75 | returns the unit number of the device file if found; otherwise | |
76 | the value zero is returned. | |
77 | .Sh FILES | |
78 | .Bl -tag -width /etc/ttys -compact | |
79 | .It Pa /dev/\(** | |
80 | .It Pa /etc/ttys | |
81 | .El | |
82 | .Sh SEE ALSO | |
83 | .Xr ioctl 2 , | |
84 | .Xr ttys 5 | |
85 | .Sh HISTORY | |
86 | A | |
87 | .Fn isatty , | |
88 | .Fn ttyname , | |
89 | and | |
90 | .Fn ttyslot | |
91 | function | |
92 | appeared in | |
93 | .At v7 . | |
94 | .Sh BUGS | |
95 | The | |
96 | .Fn ttyname | |
97 | function leaves its result in an internal static object and returns | |
98 | a pointer to that object. Subsequent calls to | |
99 | .Fn ttyname | |
100 | will modify the same object. |