posix_openpt()

Open a pseudo-terminal device

Synopsis:

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

int posix_openpt( int oflag );

Arguments:

oflag
Flags that specify the file status flags and file access modes of the open file description; a combination of the following:
  • O_RDWR — open for reading and writing.
  • O_NOCTTY — don't make the terminal device become the controlling terminal for the process.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Note: This function is in libc.a, but not in libc.so (in order to save space).

Description:

The posix_openpt() function establishes a connection between a master device for a pseudo-terminal and a file descriptor. The file descriptor is used by other I/O functions that refer to that pseudo-terminal.

Returns:

A file descriptor for the master pseudo-terminal, or -1 if an error occurred (errno is set).

Errors:

EMFILE
All file descriptors available to the process are currently open.
ENFILE
The maximum allowable number of files is currently open in the system.
EINVAL
The value of oflag isn't valid.
EAGAIN
Out of pseudo-terminal resources.

Classification:

POSIX 1003.1 XSI

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes