xref: /csrg-svn/lib/libc/gen/ttyname.3 (revision 61111)
1*61111Sbostic.\" Copyright (c) 1991, 1993
2*61111Sbostic.\"	The Regents of the University of California.  All rights reserved.
320379Smckusick.\"
448352Scael.\" %sccs.include.redist.man%
548352Scael.\"
6*61111Sbostic.\"     @(#)ttyname.3	8.1 (Berkeley) 06/04/93
748352Scael.\"
848352Scael.Dd
948352Scael.Dt TTYNAME 3
1048352Scael.Os
1148352Scael.Sh NAME
1248352Scael.Nm ttyname ,
1348352Scael.Nm isatty ,
1448352Scael.Nm ttyslot
1548352Scael.Nd get name of associated terminal (tty) from file descriptor
1648352Scael.Sh SYNOPSIS
1748352Scael.Fd #include <unistd.h>
1848352Scael.Ft char *
1948352Scael.Fn ttyname "int fd"
2048352Scael.Ft int
2148352Scael.Fn isatty "int fd"
2248352Scael.Ft int
2348352Scael.Fn ttyslot
2448352Scael.Sh DESCRIPTION
2548352ScaelThese functions operate on the system file descriptors for terminal
2648352Scaeltype devices. These descriptors are not related to the standard
2748352Scael.Tn I/O
2848352Scael.Dv FILE
2948352Scaeltypedef, but refer to the special device files found in
3048352Scael.Pa /dev
3148352Scaeland named
3248352Scael.Pa /dev/tty Ns Em xx
3348352Scaeland for which an entry exists
3448352Scaelin the initialization file
3548352Scael.Pa /etc/ttys.
3648352Scael(See
3748352Scael.Xr ttys 5 . )
3848352Scael.Pp
3948352ScaelThe
4048352Scael.Fn isatty
4148352Scaelfunction
4248352Scaeldetermines if the file descriptor
4348352Scael.Fa fd
4448352Scaelrefers to a valid
4548352Scaelterminal type device.
4648352Scael.Pp
4748352ScaelThe
4848352Scael.Fn ttyname
4948352Scaelfunction
5048352Scaelgets the related device name of
5148352Scaela file descriptor for which
5248352Scael.Fn isatty
5348352Scaelis true
5448352Scael.Pp
5548352ScaelThe
5648352Scael.Fn ttyslot
5748352Scaelfunction
5848352Scaelfetches the current process' control terminal number from the
5948352Scael.Xr ttys 5
6048352Scaelfile entry.
6148352Scael.Sh RETURN VALUES
6248352ScaelThe
6348352Scael.Fn ttyname
6448352Scaelfunction
6548352Scaelreturns the null terminated name if the device is found and
6648352Scael.Fn isatty
6748352Scaelis true; otherwise
6848352Scaela
6948352Scael.Dv NULL
7048352Scaelpointer is returned.
7148352Scael.Pp
7248352ScaelThe
7348352Scael.Fn ttyslot
7448352Scaelfunction
7548352Scaelreturns the unit number of the device file if found; otherwise
7648352Scaelthe value zero is returned.
7748352Scael.Sh FILES
7848352Scael.Bl -tag -width /etc/ttys -compact
7948352Scael.It Pa /dev/\(**
8048352Scael.It Pa /etc/ttys
8148352Scael.El
8248352Scael.Sh SEE ALSO
8348352Scael.Xr ioctl 2 ,
8448352Scael.Xr ttys 5
8548352Scael.Sh HISTORY
8648352ScaelA
8748352Scael.Fn isatty ,
8848352Scael.Fn ttyname ,
8948352Scaeland
9048352Scael.Fn ttyslot
9148352Scaelfunction
9248352Scaelappeared in
9348352Scael.At v7 .
9448352Scael.Sh BUGS
9548352ScaelThe
9648352Scael.Fn ttyname
9748352Scaelfunction leaves its result in an internal static object and returns
9848352Scaela pointer to that object. Subsequent calls to
9948352Scael.Fn ttyname
10048352Scaelwill modify the same object.
101