NAME
posix_openpt
—
open 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>
:
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
STANDARDS
The posix_openpt
() function conforms to
IEEE Std 1003.1-2001 (“POSIX.1”).
HISTORY
The posix_openpt
() function appeared in
OpenBSD 5.3.