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 > G

grantpt(3C)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

grantpt — grant access to the STREAMS slave pty

SYNOPSIS

int grantpt (int fildes);

DESCRIPTION

The passed parameter, fildes, is a file descriptor that is returned from a successful open of a STREAMS master pty (pseudo-terminal) device. The grantpt() function modifies the ownership and mode of the slave pty device special file associated with its master pty counterpart.

A setuid() root program is spawned to change ownership and mode of the pty slave device file in the following way: The group ID is set to a reserved group named "tty". The slave user ID is set to the effective owner of the calling process. The permissions of the slave device are set so that the owner is allowed read and write access and the group is allowed write access.

RETURN VALUE

Upon successful completion, the grantpt() function returns a value of 0 (zero). Otherwise, it returns a value of -1.

Failure may result under the following conditions:

  • The file descriptor specified by the fildes parameter is not an open file descriptor.

  • The file descriptor specified by the fildes parameter is not associated with a STREAMS master pty device.

  • The corresponding slave pty device cannot be accessed.

WARNINGS

The grantpt() function may also fail if the application has installed a signal handler to catch the SIGCHLD (death of a child) signal.

EXAMPLES

The following example shows how grantpt() is typically used.

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

grantpt() was 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.