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