blob: 2db75030b47e84ab53e41daf05cca916899bfd37 [file] [log] [blame]
Fred Drakea4b5d581999-06-29 18:11:22 +00001\section{\module{pty} ---
2 Pseudo-terminal utilities}
3\declaremodule{standard}{pty}
Fred Drake38e5d272000-04-03 20:13:55 +00004 \platform{IRIX, Linux}
Fred Drakea4b5d581999-06-29 18:11:22 +00005\modulesynopsis{Pseudo-Terminal Handling for SGI and Linux.}
6\moduleauthor{Steen Lumholt}{}
Fred Drake57657bc2000-12-01 15:25:23 +00007\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
Fred Drakea4b5d581999-06-29 18:11:22 +00008
9
10The \module{pty} module defines operations for handling the
11pseudo-terminal concept: starting another process and being able to
12write to and read from its controlling terminal programmatically.
13
14Because pseudo-terminal handling is highly platform dependant, there
15is code to do it only for SGI and Linux. (The Linux code is supposed
16to work on other platforms, but hasn't been tested yet.)
17
18The \module{pty} module defines the following functions:
19
20\begin{funcdesc}{fork}{}
21Fork. Connect the child's controlling terminal to a pseudo-terminal.
22Return value is \code{(\var{pid}, \var{fd})}. Note that the child
23gets \var{pid} 0, and the \var{fd} is \emph{invalid}. The parent's
24return value is the \var{pid} of the child, and \var{fd} is a file
25descriptor connected to the child's controlling terminal (and also
Fred Drake7938fab2002-05-01 03:23:03 +000026to the child's standard input and output).
Fred Drakea4b5d581999-06-29 18:11:22 +000027\end{funcdesc}
28
Fred Drakec82634c2000-06-28 17:27:48 +000029\begin{funcdesc}{openpty}{}
30Open a new pseudo-terminal pair, using \function{os.openpty()} if
31possible, or emulation code for SGI and generic \UNIX{} systems.
32Return a pair of file descriptors \code{(\var{master}, \var{slave})},
33for the master and the slave end, respectively.
34\end{funcdesc}
35
Fred Drakea4b5d581999-06-29 18:11:22 +000036\begin{funcdesc}{spawn}{argv\optional{, master_read\optional{, stdin_read}}}
37Spawn a process, and connect its controlling terminal with the current
38process's standard io. This is often used to baffle programs which
39insist on reading from the controlling terminal.
40
41The functions \var{master_read} and \var{stdin_read} should be
42functions which read from a file-descriptor. The defaults try to read
431024 bytes each time they are called.
44\end{funcdesc}