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