| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="module-fcntl.html" /> |
| 13 | <link rel="prev" href="module-tty.html" /> |
| 14 | <link rel="parent" href="unix.html" /> |
| 15 | <link rel="next" href="module-fcntl.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>8.10 pty -- Pseudo-terminal utilities</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="8.9 tty " |
| 25 | href="module-tty.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" |
| 28 | href="unix.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="8.11 fcntl " |
| 31 | href="module-fcntl.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="module-tty.html">8.9 tty </A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="module-fcntl.html">8.11 fcntl </A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H1><A NAME="SECTION00101000000000000000000"> |
| 56 | 8.10 <tt class="module">pty</tt> -- |
| 57 | Pseudo-terminal utilities</A> |
| 58 | </H1> |
| 59 | <A NAME="module-pty"></A> |
| 60 | <p class="availability">Availability: <span |
| 61 | class="platform">IRIX, Linux</span>.</p> |
| 62 | |
| 63 | <P> |
| 64 | The <tt class="module">pty</tt> module defines operations for handling the |
| 65 | pseudo-terminal concept: starting another process and being able to |
| 66 | write to and read from its controlling terminal programmatically. |
| 67 | |
| 68 | <P> |
| 69 | Because pseudo-terminal handling is highly platform dependant, there |
| 70 | is code to do it only for SGI and Linux. (The Linux code is supposed |
| 71 | to work on other platforms, but hasn't been tested yet.) |
| 72 | |
| 73 | <P> |
| 74 | The <tt class="module">pty</tt> module defines the following functions: |
| 75 | |
| 76 | <P> |
| 77 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 78 | <td><nobr><b><tt id='l2h-3020' xml:id='l2h-3020' class="function">fork</tt></b>(</nobr></td> |
| 79 | <td><var></var>)</td></tr></table></dt> |
| 80 | <dd> |
| 81 | Fork. Connect the child's controlling terminal to a pseudo-terminal. |
| 82 | Return value is <code>(<var>pid</var>, <var>fd</var>)</code>. Note that the child |
| 83 | gets <var>pid</var> 0, and the <var>fd</var> is <em>invalid</em>. The parent's |
| 84 | return value is the <var>pid</var> of the child, and <var>fd</var> is a file |
| 85 | descriptor connected to the child's controlling terminal (and also |
| 86 | to the child's standard input and output). |
| 87 | </dl> |
| 88 | |
| 89 | <P> |
| 90 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 91 | <td><nobr><b><tt id='l2h-3021' xml:id='l2h-3021' class="function">openpty</tt></b>(</nobr></td> |
| 92 | <td><var></var>)</td></tr></table></dt> |
| 93 | <dd> |
| 94 | Open a new pseudo-terminal pair, using <tt class="function">os.openpty()</tt> if |
| 95 | possible, or emulation code for SGI and generic <span class="Unix">Unix</span> systems. |
| 96 | Return a pair of file descriptors <code>(<var>master</var>, <var>slave</var>)</code>, |
| 97 | for the master and the slave end, respectively. |
| 98 | </dl> |
| 99 | |
| 100 | <P> |
| 101 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 102 | <td><nobr><b><tt id='l2h-3022' xml:id='l2h-3022' class="function">spawn</tt></b>(</nobr></td> |
| 103 | <td><var>argv</var><big>[</big><var>, master_read</var><big>[</big><var>, stdin_read</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 104 | <dd> |
| 105 | Spawn a process, and connect its controlling terminal with the current |
| 106 | process's standard io. This is often used to baffle programs which |
| 107 | insist on reading from the controlling terminal. |
| 108 | |
| 109 | <P> |
| 110 | The functions <var>master_read</var> and <var>stdin_read</var> should be |
| 111 | functions which read from a file-descriptor. The defaults try to read |
| 112 | 1024 bytes each time they are called. |
| 113 | </dl> |
| 114 | |
| 115 | <DIV CLASS="navigation"> |
| 116 | <div class='online-navigation'> |
| 117 | <p></p><hr /> |
| 118 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 119 | <tr> |
| 120 | <td class='online-navigation'><a rel="prev" title="8.9 tty " |
| 121 | href="module-tty.html"><img src='../icons/previous.png' |
| 122 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 123 | <td class='online-navigation'><a rel="parent" title="8. Unix Specific Services" |
| 124 | href="unix.html"><img src='../icons/up.png' |
| 125 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 126 | <td class='online-navigation'><a rel="next" title="8.11 fcntl " |
| 127 | href="module-fcntl.html"><img src='../icons/next.png' |
| 128 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 129 | <td align="center" width="100%">Python Library Reference</td> |
| 130 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 131 | href="contents.html"><img src='../icons/contents.png' |
| 132 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 133 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 134 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 135 | <td class='online-navigation'><a rel="index" title="Index" |
| 136 | href="genindex.html"><img src='../icons/index.png' |
| 137 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 138 | </tr></table> |
| 139 | <div class='online-navigation'> |
| 140 | <b class="navlabel">Previous:</b> |
| 141 | <a class="sectref" rel="prev" href="module-tty.html">8.9 tty </A> |
| 142 | <b class="navlabel">Up:</b> |
| 143 | <a class="sectref" rel="parent" href="unix.html">8. Unix Specific Services</A> |
| 144 | <b class="navlabel">Next:</b> |
| 145 | <a class="sectref" rel="next" href="module-fcntl.html">8.11 fcntl </A> |
| 146 | </div> |
| 147 | </div> |
| 148 | <hr /> |
| 149 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 150 | </DIV> |
| 151 | <!--End of Navigation Panel--> |
| 152 | <ADDRESS> |
| 153 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 154 | </ADDRESS> |
| 155 | </BODY> |
| 156 | </HTML> |