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