1 .\" Copyright (c) 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
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.
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.
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.
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
24 .\" Modified 2001-12-13, Martin Schulze <joey@infodrom.org>
25 .\" Added ttyname_r, aeb, 2002-07-20
27 .TH TTYNAME 3 2013-06-21 "Linux" "Linux Programmer's Manual"
29 ttyname, ttyname_r \- return name of a terminal
32 .B #include <unistd.h>
34 .BI "char *ttyname(int " fd );
36 .BI "int ttyname_r(int " fd ", char *" buf ", size_t " buflen );
41 returns a pointer to the null-terminated pathname of the terminal device
42 that is open on the file descriptor \fIfd\fP, or NULL on error
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
48 stores this pathname in the buffer
55 returns a pointer to a pathname on success.
56 On error, NULL is returned, and
61 returns 0 on success, and an error number upon error.
68 File descriptor does not refer to a terminal device.
73 was too small to allow storing the pathname.
75 .SS Multithreading (see pthreads(7))
78 function is not thread-safe.
82 function is thread-safe.