OpenBSD manual page server

Manual Page Search Parameters

POSIX_OPENPT(3) Library Functions Manual POSIX_OPENPT(3)

posix_openptopen a pseudo-terminal device

#include <stdlib.h>
#include <fcntl.h>

int
posix_openpt(int oflag);

The () 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 () function. Note that the () and () 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>:

Open for reading and writing.
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, () will return an error.

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.

The posix_openpt() function will fail if:

[]
The per-process descriptor table is full.
[]
The system file table is full.
[]
The value of oflag is not valid.

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

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

The posix_openpt() function appeared in OpenBSD 5.3.

January 25, 2019 OpenBSD-current