HP-UX Reference (11i v1 00/12) - 3 Library Functions N-Z (vol 7)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/nan.3m
________________________________________________________________
___ ___
p
ptsname(3C) ptsname(3C)
NAME
ptsname, ptsname_r - get the pathname of a slave pty (pseudo-terminal)
SYNOPSIS
#include <stdlib.h>
char * ptsname (int fildes);
char * ptsname_r (int fildes, char *slavename, int len);
Remarks:
ptsname() and ptsname_r() support STREAMS pty (see ptm(7) and pts(7)), and non-
STREAMS pty (see pty(7)) which have different device naming conventions. Notice that the
STREAMS pty, being an optional feature, is supported only when it is installed on the system.
ptsname() and ptsname_r() are useful only on systems that follow the insf(1M) naming con-
ventions for pty (STREAMS and non-STREAMS).
DESCRIPTION
The passed parameter, fildes, is a file descriptor of an opened master pty.
ptsname() generates the
name of the slave pty corresponding to this master pty. This means that their minor numbers will be
identical.
ptsname_r() is the reentrant version of the ptsname() function. The passed parameter, slavename,
is a pointer to a character array for the resulting null-terminated pathname of the slave pty. The passed
parameter, len, indicates the length of this character array which must be at least 32 bytes long.
RETURN VALUE
Upon successful completion, ptsname() returns a string containing the full path name of a slave pty.
Otherwise, a NULL pointer is returned. The return value is pointed to static data area which is overwrit-
ten with each call to ptsname(), so it should be copied if it is to be saved.
Upon successful completion, ptsname_r() stores the resulting slave name in the character array
pointed to by the slavename parameter, and returns a value of 0 (zero). Otherwise, it returns a value of -1.
ERRORS
ptsname() fails and returns a NULL pointer under the following conditions:
File descriptor does not refer to an open master pty.
Request falls outside pty name-space.
Pty device naming conventions have not been followed.
ptsname() failed to find a match.
ptsname_r() also fails under the above-mentioned conditions but instead it returns a -1 and sets
errno to ENXIO.
ptsname_r() returns a -1 and sets errno to ERANGE if the slavename parameter is invalid or the
len parameter is too small,
EXAMPLES
The following example shows how ptsname() is typically used for non-STREAMS pty to obtain the path-
name of the slave pty corresponding to a master pty obtained through a pty clone open.
int fd_master;
char *path;
...
fd_master = open("/dev/ptym/clone", O_RDONLY);
path = ptsname(fd_master);
The following example shows how ptsname() is typically used on obtaining the pathname of the
STREAMS slave pty corresponding to a STREAMS master pty.
int fd_master, fd_slave;
char *slave;
...
HP-UX Release 11i: December 2000 1 Section 3727
___
___