grantpt()

NAME

grantpt(), unlockpt() - Manipulate pty descriptors

SYNOPSIS

#include <stdlib.h>

int grantpt(int fildes) int unlockpt(int fildes)

DESCRIPTION

The grantpt(2) function takes as an argument a master pseudo-terminal device, fildes, and changes the mode and ownership of the corresponding subordinate (also known as slave) pseudo-terminal device. The subordinate's user ID is set to the calling process' real user ID, and the subordinate's permissions are set to readable and writable by the owner, and writable by the group.

Note: This implementation catches errors but does not actually change the mode and ownership.

The unlockpt(2) function unlocks the subordinate pseudo-terminal device associated with a master pseudo-terminal device; the master pseudo-terminal device is indicated by fildes.

RETURN VALUE

Both grantpt(2) and unlockpt(2) return 0 on success, or -1 on failure. If one of these functions fails, it sets errno to indicate the error.

ERRORS

The grantpt(2) and unlockpt(2) calls might fail for the following reasons:

[EBADF]
The descriptor fildes is not a valid open file descriptor.
[EINVAL]
The descriptor fildes does not actually indicate a master pseudo-terminal device.

The grantpt(2) call might also fail for the following reason:

[EACCES]
The corresponding subordinate pseudo-terminal could not be accessed.

NOTES

These implementations will catch errors, but they do not actually change the mode and ownership (for grantpt(2)) or unlock the subordinate pseudo terminal device (for unlockpt(2)).

SEE ALSO

ioctl(2)

open(2)

ptsname(2)

pty(4)

tty(4)