grantpt()

Updated: April 19, 2023

Grant access to a slave pseudo-terminal device

Synopsis:

#include <stdlib.h>

int grantpt( int filedes );

Arguments:

filedes
The file descriptor of a master pseudo-terminal device.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The grantpt() function changes the mode and ownership of the slave pseudo-terminal device associated with its master pseudo-terminal counterpart. The filedes argument is a file descriptor that refers to a master pseudo-terminal device. The user and group IDs of the slave are set to the real user and group IDs of the calling process. The permission mode of the slave pseudo-terminal is set to readable and writable by the owner, and writable by the group.

Returns:

0, or -1 if an error occurred (errno is set).

Errors:

EBADF
The filedes argument isn't a valid open file descriptor.
EINTR
The call was interrupted by a signal.
EINVAL
The filedes argument isn't associated with a master pseudo-terminal device.
EACCES
The corresponding slave pseudo-terminal device couldn't be accessed.

Classification:

POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes