ttyname.3 (8dcb56dc7885d7310299a09a04fb5334f8d75d7a) | ttyname.3 (f789cb829380f2501402d11904f10adf363f7da5) |
---|---|
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. --- 71 unchanged lines hidden (view full) --- 80The 81.Fn ttyname 82function 83gets the related device name of 84a file descriptor for which 85.Fn isatty 86is true. 87.Pp | 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. --- 71 unchanged lines hidden (view full) --- 80The 81.Fn ttyname 82function 83gets the related device name of 84a file descriptor for which 85.Fn isatty 86is true. 87.Pp |
88The |
|
88.Fn ttyname | 89.Fn ttyname |
90function |
|
89returns the name stored in a static buffer which will be overwritten 90on subsequent calls. | 91returns the name stored in a static buffer which will be overwritten 92on subsequent calls. |
93The |
|
91.Fn ttyname_r | 94.Fn ttyname_r |
95function |
|
92takes a buffer and length as arguments to avoid this problem. 93.Pp 94The 95.Fn ttyslot 96function 97fetches the current process' control terminal number from the 98.Xr ttys 5 99file entry. --- 4 unchanged lines hidden (view full) --- 104returns the null terminated name if the device is found and 105.Fn isatty 106is true; otherwise 107a 108.Dv NULL 109pointer is returned. 110The 111.Fn ttyname_r | 96takes a buffer and length as arguments to avoid this problem. 97.Pp 98The 99.Fn ttyslot 100function 101fetches the current process' control terminal number from the 102.Xr ttys 5 103file entry. --- 4 unchanged lines hidden (view full) --- 108returns the null terminated name if the device is found and 109.Fn isatty 110is true; otherwise 111a 112.Dv NULL 113pointer is returned. 114The 115.Fn ttyname_r |
112function returns 0 if successful. Otherwise an error number is returned. | 116function returns 0 if successful. 117Otherwise an error number is returned. |
113.Pp 114The 115.Fn ttyslot 116function 117returns the unit number of the device file if found; otherwise 118the value zero is returned. | 118.Pp 119The 120.Fn ttyslot 121function 122returns the unit number of the device file if found; otherwise 123the value zero is returned. |
124.Sh FILES 125.Bl -tag -width ".Pa /etc/ttys" -compact 126.It Pa /dev/\(** 127.It Pa /etc/ttys 128.El |
|
119.Sh ERRORS | 129.Sh ERRORS |
130The |
|
120.Fn ttyname_r | 131.Fn ttyname_r |
121may return the following error codes: | 132may fail and return the following error codes: |
122.Bl -tag -width Er 123.It Bq Er ENOTTY | 133.Bl -tag -width Er 134.It Bq Er ENOTTY |
135The |
|
124.Fa fd | 136.Fa fd |
137argument |
|
125is not a valid file descriptor. 126.It Bq Er ERANGE | 138is not a valid file descriptor. 139.It Bq Er ERANGE |
140The |
|
127.Fa bufsize | 141.Fa bufsize |
142argument |
|
128is smaller than the length of the string to be returned. | 143is smaller than the length of the string to be returned. |
129.Sh FILES 130.Bl -tag -width /etc/ttys -compact 131.It Pa /dev/\(** 132.It Pa /etc/ttys | |
133.El 134.Sh SEE ALSO 135.Xr ioctl 2 , 136.Xr ttys 5 137.Sh HISTORY | 144.El 145.Sh SEE ALSO 146.Xr ioctl 2 , 147.Xr ttys 5 148.Sh HISTORY |
138A | 149The |
139.Fn isatty , 140.Fn ttyname , 141and 142.Fn ttyslot | 150.Fn isatty , 151.Fn ttyname , 152and 153.Fn ttyslot |
143function | 154functions |
144appeared in 145.At v7 . | 155appeared in 156.At v7 . |
157The |
|
146.Fn ttyname_r | 158.Fn ttyname_r |
159function |
|
147appeared in 148.Fx 6.0 . | 160appeared in 161.Fx 6.0 . |