]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1995 Jim Van Zandt <jrv@vanzandt.mv.com> |
2 | .\" | |
6a8d8745 | 3 | .\" %%%LICENSE_START(GPLv2+_doc_full) |
fea681da MK |
4 | .\" This is free documentation; you can redistribute it and/or |
5 | .\" modify it under the terms of the GNU General Public License as | |
6 | .\" published by the Free Software Foundation; either version 2 of | |
7 | .\" the License, or (at your option) any later version. | |
8 | .\" | |
9 | .\" The GNU General Public License's references to "object code" | |
10 | .\" and "executables" are to be interpreted as the output of any | |
11 | .\" document formatting or typesetting system, including | |
12 | .\" intermediate and printed output. | |
13 | .\" | |
14 | .\" This manual is distributed in the hope that it will be useful, | |
15 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | .\" GNU General Public License for more details. | |
18 | .\" | |
19 | .\" You should have received a copy of the GNU General Public | |
c715f741 MK |
20 | .\" License along with this manual; if not, see |
21 | .\" <http://www.gnu.org/licenses/>. | |
6a8d8745 | 22 | .\" %%%LICENSE_END |
c13182ef | 23 | .\" |
fea681da MK |
24 | .\" Modified 2001-12-13, Martin Schulze <joey@infodrom.org> |
25 | .\" Added ttyname_r, aeb, 2002-07-20 | |
26 | .\" | |
cd56c2fc | 27 | .TH TTYNAME 3 2012-12-21 "Linux" "Linux Programmer's Manual" |
fea681da MK |
28 | .SH NAME |
29 | ttyname, ttyname_r \- return name of a terminal | |
30 | .SH SYNOPSIS | |
31 | .nf | |
32 | .B #include <unistd.h> | |
33 | .sp | |
34 | .BI "char *ttyname(int " fd ); | |
5895e7eb | 35 | |
fea681da MK |
36 | .BI "int ttyname_r(int " fd ", char *" buf ", size_t " buflen ); |
37 | .fi | |
38 | .SH DESCRIPTION | |
39 | The function | |
40 | .BR ttyname () | |
28d88c17 | 41 | returns a pointer to the null-terminated pathname of the terminal device |
35e21ba7 | 42 | that is open on the file descriptor \fIfd\fP, or NULL on error |
fea681da MK |
43 | (for example, if \fIfd\fP is not connected to a terminal). |
44 | The return value may point to static data, possibly overwritten by the | |
45 | next call. | |
46 | The function | |
47 | .BR ttyname_r () | |
48 | stores this pathname in the buffer | |
49 | .I buf | |
50 | of length | |
51 | .IR buflen . | |
47297adb | 52 | .SH RETURN VALUE |
fea681da MK |
53 | The function |
54 | .BR ttyname () | |
c13182ef | 55 | returns a pointer to a pathname on success. |
8478ee02 | 56 | On error, NULL is returned, and |
fea681da MK |
57 | .I errno |
58 | is set appropriately. | |
59 | The function | |
60 | .BR ttyname_r () | |
61 | returns 0 on success, and an error number upon error. | |
62 | .SH ERRORS | |
fea681da MK |
63 | .TP |
64 | .B EBADF | |
65 | Bad file descriptor. | |
66 | .TP | |
67 | .B ENOTTY | |
68 | File descriptor does not refer to a terminal device. | |
69 | .TP | |
70 | .B ERANGE | |
4bcf0534 | 71 | .RB ( ttyname_r ()) |
fea681da MK |
72 | .I buflen |
73 | was too small to allow storing the pathname. | |
47297adb | 74 | .SH CONFORMING TO |
68e1685c | 75 | 4.2BSD, POSIX.1-2001. |
47297adb | 76 | .SH SEE ALSO |
fea681da | 77 | .BR fstat (2), |
cd12460a | 78 | .BR ctermid (3), |
fea681da | 79 | .BR isatty (3) |