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 worker pseudo-terminal associated with the controller pseudo-terminal device defined by the FileDescriptor parameter. The user ID of the worker pseudo-terminal is set to the real UID of the calling process. The group ID of the worker pseudo-terminal is set to an unspecified group ID. The permission mode of the worker 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 controller 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 controller pseudo-terminal device.
EACCES The corresponding worker pseudo-terminal device could not be accessed.