Pseudo-terminal utilities
=========================
Pseudo-Terminal Handling for SGI and Linux. This module was written by
Steen Lumholt <>.
This manual section was written by Moshe Zadka
<moshez@zadka.site.co.il>.
The `pty' module defines operations for handling the pseudo-terminal
concept: starting another process and being able to write to and read
from its controlling terminal programmatically.
Because pseudo-terminal handling is highly platform dependant, there is
code to do it only for SGI and Linux. (The Linux code is supposed to
work on other platforms, but hasn't been tested yet.)
The `pty' module defines the following functions:
`fork()'
Fork. Connect the child's controlling terminal to a
pseudo-terminal. Return value is `(PID, FD)'. Note that the child
gets PID 0, and the FD is _invalid_. The parent's return value is
the PID of the child, and FD is a file descriptor connected to the
child's controlling terminal (and also to the child's standard
input and output.
`openpty()'
Open a new pseudo-terminal pair, using `os.openpty()' if possible,
or emulation code for SGI and generic UNIX systems. Return a pair
of file descriptors `(MASTER, SLAVE)', for the master and the
slave end, respectively.
`spawn(argv[, master_read[, stdin_read]])'
Spawn a process, and connect its controlling terminal with the
current process's standard io. This is often used to baffle
programs which insist on reading from the controlling terminal.
The functions MASTER_READ and STDIN_READ should be functions which
read from a file-descriptor. The defaults try to read 1024 bytes
each time they are called.