Blame man3/ptsname.3

Packit 7cfc04
.\" %%%LICENSE_START(PUBLIC_DOMAIN)
Packit 7cfc04
.\" This page is in the public domain. - aeb
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" 2004-12-17, mtk, added description of ptsname_r() + ERRORS
Packit 7cfc04
.\"
Packit 7cfc04
.TH PTSNAME 3 2017-09-15 "" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
ptsname, ptsname_r \- get the name of the slave pseudoterminal
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <stdlib.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "char *ptsname(int " fd ");"
Packit 7cfc04
.br
Packit 7cfc04
.BI "int ptsname_r(int " fd ", char *" buf ", size_t " buflen ");"
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.ad l
Packit 7cfc04
.BR ptsname ():
Packit 7cfc04
.br
Packit 7cfc04
.RS 4
Packit 7cfc04
Since glibc 2.24:
Packit 7cfc04
    _XOPEN_SOURCE\ >=\ 500 ||
Packit 7cfc04
        (_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED)
Packit 7cfc04
.br
Packit 7cfc04
Glibc 2.23 and earlier:
Packit 7cfc04
    _XOPEN_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.PP
Packit 7cfc04
.BR ptsname_r ():
Packit 7cfc04
    _GNU_SOURCE
Packit 7cfc04
.ad
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.BR ptsname ()
Packit 7cfc04
function returns the name of the slave pseudoterminal device
Packit 7cfc04
corresponding to the master referred to by
Packit 7cfc04
.IR fd .
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.BR ptsname_r ()
Packit 7cfc04
function is the reentrant equivalent of
Packit 7cfc04
.BR ptsname ().
Packit 7cfc04
It returns the name of the slave pseudoterminal device as a
Packit 7cfc04
null-terminated string in the buffer pointed to by
Packit 7cfc04
.IR buf .
Packit 7cfc04
The
Packit 7cfc04
.I buflen
Packit 7cfc04
argument specifies the number of bytes available in
Packit 7cfc04
.IR buf .
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR ptsname ()
Packit 7cfc04
returns a pointer to a string in static storage which will be
Packit 7cfc04
overwritten by subsequent calls.
Packit 7cfc04
This pointer must not be freed.
Packit 7cfc04
On failure, NULL is returned.
Packit 7cfc04
.PP
Packit 7cfc04
On success,
Packit 7cfc04
.BR ptsname_r ()
Packit 7cfc04
returns 0.
Packit 7cfc04
On failure, a nonzero value is returned
Packit 7cfc04
and
Packit 7cfc04
.I errno
Packit 7cfc04
is set to indicate the error.
Packit 7cfc04
.\" In fact the errno value is also returned as the function
Packit 7cfc04
.\" result -- MTK, Dec 04
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.RB ( ptsname_r ()
Packit 7cfc04
only)
Packit 7cfc04
.I buf
Packit 7cfc04
is NULL.
Packit 7cfc04
(This error is returned only for
Packit 7cfc04
.\" glibc commit 8f0a947cf55f3b0c4ebdf06953c57eff67a22fa9
Packit 7cfc04
glibc 2.25 and earlier.)
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOTTY
Packit 7cfc04
.I fd
Packit 7cfc04
does not refer to a pseudoterminal master device.
Packit 7cfc04
.TP
Packit 7cfc04
.B ERANGE
Packit 7cfc04
.RB ( ptsname_r ()
Packit 7cfc04
only)
Packit 7cfc04
.I buf
Packit 7cfc04
is too small.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR ptsname ()
Packit 7cfc04
is provided in glibc since version 2.1.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lb lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR ptsname ()
Packit 7cfc04
T}	Thread safety	MT-Unsafe race:ptsname
Packit 7cfc04
T{
Packit 7cfc04
.BR ptsname_r ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
.BR ptsname ():
Packit 7cfc04
 POSIX.1-2001, POSIX.1-2008.
Packit 7cfc04
.PP
Packit 7cfc04
.BR ptsname ()
Packit 7cfc04
is part of the UNIX 98 pseudoterminal support (see
Packit 7cfc04
.BR pts (4)).
Packit 7cfc04
.PP
Packit 7cfc04
.BR ptsname_r ()
Packit 7cfc04
is a Linux extension, that is proposed for inclusion
Packit 7cfc04
.\" FIXME . for later review when Issue 8 is one day released
Packit 7cfc04
.\" http://austingroupbugs.net/tag_view_page.php?tag_id=8
Packit 7cfc04
.\" http://austingroupbugs.net/view.php?id=508
Packit 7cfc04
in the next major revision of POSIX.1 (Issue 8).
Packit 7cfc04
A version of this function is documented on Tru64 and HP-UX, but
Packit 7cfc04
on those implementations, \-1 is returned on error, with
Packit 7cfc04
.I errno
Packit 7cfc04
set to indicate the error.
Packit 7cfc04
Avoid using this function in portable programs.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR grantpt (3),
Packit 7cfc04
.BR posix_openpt (3),
Packit 7cfc04
.BR ttyname (3),
Packit 7cfc04
.BR unlockpt (3),
Packit 7cfc04
.BR pts (4),
Packit 7cfc04
.BR pty (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.