forkpty()

Create a new process operating in a pseudo-tty

Synopsis:

#include <unix.h>

pid_t forkpty( int *amaster,
               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.
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 forkpty() function combines openpty(), fork(), and login_tty() to create a new process operating in a pseudo-tty.

This function fails if either openpty() or fork() fails.

Returns:

0 to the child process, the child's process ID to the parent, or -1 if an error occurred.

Classification:

Unix

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

See also:

fork(), login_tty(), openpty(), termios