]> git.saurik.com Git - apple/libc.git/blame_incremental - gen/ttyname.3
Libc-594.1.4.tar.gz
[apple/libc.git] / gen / ttyname.3
... / ...
CommitLineData
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
60These functions operate on the system file descriptors for terminal
61type devices.
62These descriptors are not related to the standard
63.Tn I/O
64.Dv FILE
65typedef, but refer to the special device files found in
66.Pa /dev
67and named
68.Pa /dev/tty Ns Ar xx
69and for which an entry exists
70in the initialization file
71.Pa /etc/ttys .
72(See
73.Xr ttys 5 . )
74.Pp
75The
76.Fn isatty
77function
78determines if the file descriptor
79.Fa fildes
80refers to a valid
81terminal type device.
82.Pp
83The
84.Fn ttyname
85function
86gets the related device name of
87a file descriptor for which
88.Fn isatty
89is true.
90.Pp
91The
92.Fn ttyslot
93function
94fetches the current process' control terminal number from the
95.Xr ttys 5
96file entry.
97.Sh RETURN VALUES
98The
99.Fn ttyname
100function
101returns the null terminated name if the device is found and
102.Fn isatty
103is true; otherwise, a
104.Dv NULL
105pointer is returned.
106.Pp
107The
108.Fn ttyslot
109function returns the unit number of the device file if found;
110otherwise, 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
120A
121.Fn isatty ,
122.Fn ttyname ,
123and
124.Fn ttyslot
125function
126appeared in
127.At v7 .
128.Sh BUGS
129The
130.Fn ttyname
131function leaves its result in an internal static object and returns
132a pointer to that object.
133Subsequent calls to
134.Fn ttyname
135will modify the same object.