Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > P

ptsname(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

ptsname() — get the pathname of a slave pty (pseudo-terminal)

SYNOPSIS

#include <stdlib.h>

char * ptsname (int fildes);

Obsolescent Interfaces

char * ptsname_r (int fildes, char *slavename, int len);

Remarks

ptsname() supports 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() is useful only on systems that follow the insf(1M) naming conventions 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.

Obsolescent Interfaces

ptsname_r() gets the pathname of a slave pty (pseudo-terminal).

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 overwritten with each call to ptsname(), so it should be copied if it is to be saved.

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.

WARNINGS

ptsname_r() is obsolescent interface supported only for compatibility with existing DCE applications. New multi-threaded applications should use ptsname().

EXAMPLES

The following example shows how ptsname() is typically used for non-STREAMS pty to obtain the pathname 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; ... fd_master = open("/dev/ptmx", O_RDWR); grantpt(fd_master); unlockpt(fd_master); slave = ptsname(fd_master); fd_slave = open(slave, O_RDWR); ioctl(fd_slave, I_PUSH, "ptem"); ioctl(fd_slave, I_PUSH, "ldterm");

AUTHOR

ptsname() and ptsname_r() were developed by HP and OSF.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.