]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ttyname.3
getgrnam.3: ATTRIBUTES: Note functions that are and aren't thread-safe
[thirdparty/man-pages.git] / man3 / ttyname.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1995 Jim Van Zandt <jrv@vanzandt.mv.com>
2.\"
1dd72f9c 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
29ttyname, 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
39The function
40.BR ttyname ()
28d88c17 41returns a pointer to the null-terminated pathname of the terminal device
35e21ba7 42that 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).
44The return value may point to static data, possibly overwritten by the
45next call.
46The function
47.BR ttyname_r ()
48stores this pathname in the buffer
49.I buf
50of length
51.IR buflen .
47297adb 52.SH RETURN VALUE
fea681da
MK
53The function
54.BR ttyname ()
c13182ef 55returns a pointer to a pathname on success.
8478ee02 56On error, NULL is returned, and
fea681da
MK
57.I errno
58is set appropriately.
59The function
60.BR ttyname_r ()
61returns 0 on success, and an error number upon error.
62.SH ERRORS
fea681da
MK
63.TP
64.B EBADF
65Bad file descriptor.
66.TP
67.B ENOTTY
68File descriptor does not refer to a terminal device.
69.TP
70.B ERANGE
4bcf0534 71.RB ( ttyname_r ())
fea681da
MK
72.I buflen
73was too small to allow storing the pathname.
47297adb 74.SH CONFORMING TO
68e1685c 754.2BSD, POSIX.1-2001.
47297adb 76.SH SEE ALSO
fea681da 77.BR fstat (2),
cd12460a 78.BR ctermid (3),
fea681da 79.BR isatty (3)