grantpt Subroutine

Purpose

Changes the mode and ownership of a pseudo-terminal device.

Library

Standard C Library (libc.a)

Syntax

#include <stdlib.h>

int grantpt ( FileDescriptor)
int FileDescriptor;

Description

The grantpt subroutine changes the mode and the ownership of the slave pseudo-terminal associated with the master pseudo-terminal device defined by the FileDescriptor parameter. The user ID of the slave pseudo-terminal is set to the real UID of the calling process. The group ID of the slave pseudo-terminal is set to an unspecified group ID. The permission mode of the slave pseudo-terminal is set to readable and writeable by the owner, and writeable by the group.

Parameters

Item Description
FileDescriptor Specifies the file descriptor of the master pseudo-terminal device.

Return Value

Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The grantpt function may fail if:

Item Description
EBADF The fildes argument is not a valid open file descriptor.
EINVAL The fildes argument is not associated with a master pseudo-terminal device.
EACCES The corresponding slave pseudo-terminal device could not be accessed.