grantpt(), unlockpt() - Manipulate pty descriptors
#include <stdlib.h>
int grantpt(int fildes)
int unlockpt(int fildes)
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.
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.
The grantpt(2) and unlockpt(2) calls might fail for the following reasons:
The grantpt(2) call might also fail for the following reason:
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)).
ioctl(2)
open(2)
ptsname(2)
pty(4)
tty(4)