Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fork(2)

openpty(3)  —  Subroutines

NAME

openpty, forkpty - Open and fork pseudoterminals

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <termios.h>
             <ioctl.h> int openpty(
int ∗master,
int ∗slave,
char ∗name,
struct termios ∗termp,
struct winsize ∗winp,); pid_t  forkpty(
int ∗master,
char ∗name,
struct termios ∗termp,
struct winsize ∗winp,);

PARAMETERS

masterPoints to the returned file descriptor for the master pty. 

slavePoints to the returned file descriptor for the slave pty. 

namePoints to the pathname of the slave pseudoterminal (pty).  This parameter is optional. 

termpSpecifies the termios structure containing the terminal attributes for the opened slave pty.  This parameter is optional. 

winpSpecifies the winsize structure containing the window attributes for the opened slave pty.  This parameter is optional. 

DESCRIPTION

The openpty() function opens the pty master/slave pair and sets the terminal attributes of the slave pseudoterminal according to the specifications in the termp and winp parameters.  The forkpty() function creates a child process and establishes the slave pty as the child process’ controlling terminal. 

Note

If a signal handler for SIGCHLD exists and the openpty() or forkpty() function is invoked without superuser privileges, the signal handler must be able to dismiss an unexpected SIGCHLD signal. 

RETURN VALUES

Upon successful completion, the openpty() function returns a value of 0 (zero).  Otherwise, it returns a value of -1. The forkpty() function returns a value of 0 (zero) to the child process and returns the process ID of the child process to the parent process on success.  On error, the forkpty() function returns a value of -1 to the parent process and does not create a child process. 

ERRORS

If any of the following conditions occurs, the openpty() function sets errno to the corresponding value:

[ENOENT]The slave pty special files have been exhausted. 

[ENXIO]There are no more ptys that can be opened.  The configured number of ptys has been reached. 

[EMFILE]The system limit for open file descriptors per process has already reached OPEN_MAX.  The system limit for open file descriptors has already been reached. 

[ENFILE]The system file table is full. 

[ENOMEM]The system was unable to allocate kernel memory for more file descriptors/processes. 

[EAGAIN]The system-imposed limit on the total number of processes executing for a single user has been exceeded.  This limit can be exceeded by a process with superuser privilege. 

RELATED INFORMATION

Functions: fork(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026