man-pages/man3/ptsname.3

96 lines
2.1 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
.\" Hey Emacs! This file is -*- nroff -*- source.
.\" This page is in the public domain. - aeb
.\"
2004-12-17 11:22:41 +00:00
.\" 2004-12-17, mtk, added description of ptsname_r() + ERRORS
.\"
2007-05-18 09:11:21 +00:00
.TH PTSNAME 3 2004-12-17 "" "Linux Programmer's Manual"
2004-11-03 13:51:07 +00:00
.SH NAME
ptsname, ptsname_r \- get the name of the slave pseudo-terminal
2004-11-03 13:51:07 +00:00
.SH SYNOPSIS
.nf
.B #define _XOPEN_SOURCE
.br
.B #include <stdlib.h>
.sp
.BI "char *ptsname(int " fd ");"
2004-12-17 11:22:41 +00:00
.sp
.B #define _GNU_SOURCE
.br
.B #include <stdlib.h>
.sp
2007-04-03 15:32:52 +00:00
.BI "char *ptsname_r(int " fd ", char *" buf ", size_t " buflen ");"
2004-11-03 13:51:07 +00:00
.fi
.SH DESCRIPTION
The
.BR ptsname ()
2004-12-17 11:22:41 +00:00
function returns the name of the slave pseudo-terminal (pty) device
corresponding to the master referred to by
2004-11-03 13:51:07 +00:00
.IR fd .
2004-12-17 11:22:41 +00:00
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 .
2004-11-03 13:51:07 +00:00
.SH "RETURN VALUE"
2004-12-17 11:22:41 +00:00
On success,
2004-11-03 13:51:07 +00:00
.BR ptsname ()
2004-12-17 11:22:41 +00:00
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.
2008-03-19 13:16:39 +00:00
On failure, a non-zero value is returned
2004-12-17 11:22:41 +00:00
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.
2004-11-03 13:51:07 +00:00
.SH "CONFORMING TO"
2004-12-17 11:22:41 +00:00
.BR ptsname ()
is part of the Unix98 pseudo-terminal support (see
.BR pts (4)).
2006-08-03 13:57:30 +00:00
This function is specified in POSIX.1-2001.
2004-12-17 11:22:41 +00:00
2005-04-18 13:35:29 +00:00
.BR ptsname_r ()
2004-12-17 11:22:41 +00:00
is a Linux extension.
2004-12-17 12:40:52 +00:00
A version of this function is documented on Tru64 and HP-UX, but
2005-06-15 14:10:23 +00:00
on those implementations, \-1 is returned on error, with
2004-12-17 11:22:41 +00:00
.I errno
set to indicate the error.
Avoid using this function in portable programs.
2004-11-03 13:51:07 +00:00
.SH "SEE ALSO"
.BR grantpt (3),
2004-12-17 12:46:00 +00:00
.BR posix_openpt (3),
2004-11-03 13:51:07 +00:00
.BR ttyname (3),
2004-12-17 12:46:00 +00:00
.BR unlockpt (3),
2005-10-10 13:14:12 +00:00
.BR pts (4),
2007-01-28 20:00:24 +00:00
.BR feature_test_macros (7),
2005-10-10 13:14:12 +00:00
.BR pty (7)