Added ptsname_r() and ERRORS

This commit is contained in:
Michael Kerrisk 2004-12-17 11:22:41 +00:00
parent b05200f368
commit 728976484c
1 changed files with 68 additions and 14 deletions

View File

@ -1,9 +1,11 @@
.\" Hey Emacs! This file is -*- nroff -*- source.
.\" This page is in the public domain. - aeb
.\"
.TH PTSNAME 3 "2003-01-30" "PTY Control" "Linux Programmer's Manual"
.\" 2004-12-17, mtk, added description of ptsname_r() + ERRORS
.\"
.TH PTSNAME 3 "2004-12-17" "PTY Control" "Linux Programmer's Manual"
.SH NAME
ptsname \- get the name of the slave pseudotty
ptsname, ptsname_r \- get the name of the slave pseudotty
.SH SYNOPSIS
.nf
.B #define _XOPEN_SOURCE
@ -11,26 +13,78 @@ ptsname \- get the name of the slave pseudotty
.B #include <stdlib.h>
.sp
.BI "char *ptsname(int " fd ");"
.sp
.B #define _GNU_SOURCE
.br
.B #include <stdlib.h>
.sp
.BI "char *ptsname_r(int " fd ", char * " buf ", size_t " buflen ");"
.fi
.SH DESCRIPTION
The
.BR ptsname ()
function returns the name of the slave pseudo-terminal device (pty)
corresponding to the master pty referred to by
function returns the name of the slave pseudo-terminal (pty) device
corresponding to the master referred to by
.IR fd .
The
.BR ptsname_r ()
function is the reentrant equivalent of
.BR ptsname ().
It returns the name of the slave pseudo-terminal device as a
null-terminated string in the buffer pointed to by
.IR buf .
The
.I buflen
argument specifies the number of bytes available in
.IR buf .
.SH "RETURN VALUE"
When successful,
On success,
.BR ptsname ()
returns a pointer to a string in static storage. This pointer
must not be freed.
.PP
Upon failure,
.BR ptsname ()
returns a NULL pointer.
returns a pointer to a string in static storage which will be
overwritten by subsequent calls.
This pointer must not be freed.
On failure, a NULL pointer is returned.
On success,
.BR ptsname_r ()
returns 0.
On failure, a non-zero value is returned
and
.I errno
is set to indicate the error.
.\" In fact the errno value is also returned as the function
.\" result -- MTK, Dec 04
.SH ERRORS
.TP
.B EINVAL
.RB ( ptsname_r ()
only)
.I buf
is NULL.
.TP
.B ENOTTY
.I fd
does not refer to a pseudo-terminal master device.
.TP
.B ERANGE
.RB ( ptsname_r ()
only)
.I buf
is too small.
.SH "CONFORMING TO"
POSIX 1003.1-2001.
This is part of the Unix98 pty support, see
.BR pts (4).
.BR ptsname ()
is part of the Unix98 pseudo-terminal support (see
.BR pts (4)).
This function is specified in POSIX 1003.1-2001.
.BR pstname_r ()
is a Linux extension.
A version of this function is provided on Tru64 and HP-UX, but
on those implementations, -1 is returned on error, with
.I errno
set to indicate the error.
Avoid using this function in portable programs.
.SH "SEE ALSO"
.BR grantpt (3),
.BR ttyname (3),