Operating systems, development tools, and professional services
for connected embedded systems

Developer Resources
Blogs
Board support packages
Foundry27 projects
Forums
Hardware support listing
Online video tutorials
Product documentation

openpty

openpty()

Find an available pseudo-tty

Synopsis:

#include <unix.h>

int openpty( int* amaster, 
             int* aslave,
             char* name,
             struct termios* termp,
             struct winsize* winp );

Arguments:

amaster
A pointer to a location where forkpty() can store the file descriptor of the master side of the pseudo-tty.
aslave
A pointer to a location where forkpty() can store the file descriptor of the slave side of the pseudo-tty.
name
NULL, or a pointer to a buffer where forkpty() can store the filename of the slave side of the pseudo-tty.
termp
NULL, or a pointer to a termios structure that describes the terminal's control attributes to apply to the slave side of the pseudo-tty.
winp
A pointer to a winsize structure that defines the window size to use for the slave side of the pseudo-tty.

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 openpty() function finds and opens an available pseudo-tty.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

ENOENT
There are no ttys available.

Classification:

Unix

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

See also:

fork(), forkpty(), login_tty(), termios