[OpenBSD]

Manual Page Search Parameters

POSIX_OPENPT(3) Library Functions Manual POSIX_OPENPT(3)

NAME

posix_openptopen a pseudo-terminal device

SYNOPSIS

#include <stdlib.h>
#include <fcntl.h>
int
posix_openpt(int oflag);

DESCRIPTION

The posix_openpt() function finds the next available pseudo-terminal and returns an open file descriptor for its master device. The path name of the slave device may be determined via the ptsname() function. Note that the unlockpt() and grantpt() functions should be called before opening the slave device.
The oflag argument is formed by bitwise-inclusive OR'ing the following values defined in <fcntl.h>:
 
 
O_RDWR
Open for reading and writing.
 
 
O_NOCTTY
Prevent the device from being made the controlling terminal for the session. This flag has no effect on OpenBSD and is included for compatibility with other systems.
The O_RDWR flag must be specified in oflag. If oflag contains values other than those listed above, posix_openpt() will return an error.

RETURN VALUES

If successful, posix_openpt() returns a non-negative integer, the file descriptor for the pseudo-terminal master device. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ERRORS

The posix_openpt() function will fail if:
 
 
[EMFILE]
The per-process descriptor table is full.
 
 
[ENFILE]
The system file table is full.
 
 
[EINVAL]
The value of oflag is not valid.

SEE ALSO

ptsname(3), pty(4), tty(4)

STANDARDS

The posix_openpt() function conforms to IEEE Std 1003.1-2001 (“POSIX.1”).

HISTORY

The posix_openpt() function appeared in OpenBSD 5.3.
December 5, 2012 OpenBSD-current