Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
pty.html477 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="pty — Pseudo-terminal utilities" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/pty.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/pty.py 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 progra..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_pty_14ddfbb8.png" />15<meta property="og:image:alt" content="Source code: Lib/pty.py 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 progra..." />16<meta name="description" content="Source code: Lib/pty.py 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 progra..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>pty — Pseudo-terminal utilities &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="fcntl — The fcntl and ioctl system calls" href="fcntl.html" />43    <link rel="prev" title="tty — Terminal control functions" href="tty.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/pty.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> — Pseudo-terminal utilities</a><ul>108<li><a class="reference internal" href="#example">Example</a></li>109</ul>110</li>111</ul>112 113  </div>114  <div>115    <h4>Previous topic</h4>116    <p class="topless"><a href="tty.html"117                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tty</span></code> — Terminal control functions</a></p>118  </div>119  <div>120    <h4>Next topic</h4>121    <p class="topless"><a href="fcntl.html"122                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">fcntl</span></code> — The <code class="docutils literal notranslate"><span class="pre">fcntl</span></code> and <code class="docutils literal notranslate"><span class="pre">ioctl</span></code> system calls</a></p>123  </div>124  <script>125    document.addEventListener('DOMContentLoaded', () => {126        const title = document.querySelector('meta[property="og:title"]').content;127        const elements = document.querySelectorAll('.improvepage');128        const pageurl = window.location.href.split('?')[0];129        elements.forEach(element => {130            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));131            url.searchParams.set('pagetitle', title);132            url.searchParams.set('pageurl', pageurl);133            url.searchParams.set('pagesource', "library/pty.rst");134            element.href = url.toString();135        });136    });137  </script>138  <div role="note" aria-label="source link">139    <h3>This page</h3>140    <ul class="this-page-menu">141      <li><a href="../bugs.html">Report a bug</a></li>142      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>143      <li>144        <a href="https://github.com/python/cpython/blob/main/Doc/library/pty.rst?plain=1"145            rel="nofollow">Show source146        </a>147      </li>148      149    </ul>150  </div>151        </nav>152    </div>153</div>154 155  156    <div class="related" role="navigation" aria-label="Related">157      <h3>Navigation</h3>158      <ul>159        <li class="right" style="margin-right: 10px">160          <a href="../genindex.html" title="General Index"161             accesskey="I">index</a></li>162        <li class="right" >163          <a href="../py-modindex.html" title="Python Module Index"164             >modules</a> |</li>165        <li class="right" >166          <a href="fcntl.html" title="fcntl — The fcntl and ioctl system calls"167             accesskey="N">next</a> |</li>168        <li class="right" >169          <a href="tty.html" title="tty — Terminal control functions"170             accesskey="P">previous</a> |</li>171 172          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>173          <li><a href="https://www.python.org/">Python</a> &#187;</li>174          <li class="switchers">175            <div class="language_switcher_placeholder"></div>176            <div class="version_switcher_placeholder"></div>177          </li>178          <li>179              180          </li>181    <li id="cpython-language-and-version">182      <a href="../index.html">3.15.0a6 Documentation</a> &#187;183    </li>184 185          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>186          <li class="nav-item nav-item-2"><a href="unix.html" accesskey="U">Unix-specific services</a> &#187;</li>187        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> — Pseudo-terminal utilities</a></li>188                <li class="right">189                    190 191    <div class="inline-search" role="search">192        <form class="inline-search" action="../search.html" method="get">193          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">194          <input type="submit" value="Go">195        </form>196    </div>197                     |198                </li>199            <li class="right">200<label class="theme-selector-label">201    Theme202    <select class="theme-selector" oninput="activateTheme(this.value)">203        <option value="auto" selected>Auto</option>204        <option value="light">Light</option>205        <option value="dark">Dark</option>206    </select>207</label> |</li>208            209      </ul>210    </div>    211 212    <div class="document">213      <div class="documentwrapper">214        <div class="bodywrapper">215          <div class="body" role="main">216            217  <section id="module-pty">218<span id="pty-pseudo-terminal-utilities"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> — Pseudo-terminal utilities<a class="headerlink" href="#module-pty" title="Link to this heading">¶</a></h1>219<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/pty.py">Lib/pty.py</a></p>220<hr class="docutils" />221<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> module defines operations for handling the pseudo-terminal222concept: starting another process and being able to write to and read from its223controlling terminal programmatically.</p>224<div class="availability docutils container">225<p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p>226</div>227<p>Pseudo-terminal handling is highly platform dependent. This code is mainly228tested on Linux, FreeBSD, and macOS (it is supposed to work on other POSIX229platforms but it’s not been thoroughly tested).</p>230<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> module defines the following functions:</p>231<dl class="py function">232<dt class="sig sig-object py" id="pty.fork">233<span class="sig-prename descclassname"><span class="pre">pty.</span></span><span class="sig-name descname"><span class="pre">fork</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pty.fork" title="Link to this definition">¶</a></dt>234<dd><p>Fork. Connect the child’s controlling terminal to a pseudo-terminal. Return235value is <code class="docutils literal notranslate"><span class="pre">(pid,</span> <span class="pre">fd)</span></code>. Note that the child  gets <em>pid</em> 0, and the <em>fd</em> is236<em>invalid</em>. The parent’s return value is the <em>pid</em> of the child, and <em>fd</em> is a237file descriptor connected to the child’s controlling terminal (and also to the238child’s standard input and output).</p>239<p>The returned file descriptor <em>fd</em> is <a class="reference internal" href="os.html#fd-inheritance"><span class="std std-ref">non-inheritable</span></a>.</p>240<div class="admonition warning">241<p class="admonition-title">Warning</p>242<p>On macOS the use of this function is unsafe when mixed with using243higher-level system APIs, and that includes using <a class="reference internal" href="urllib.request.html#module-urllib.request" title="urllib.request: Extensible library for opening URLs."><code class="xref py py-mod docutils literal notranslate"><span class="pre">urllib.request</span></code></a>.</p>244</div>245<div class="versionchanged">246<p><span class="versionmodified changed">Changed in version 3.15: </span>The returned file descriptor is now made non-inheritable.</p>247</div>248</dd></dl>249 250<dl class="py function">251<dt class="sig sig-object py" id="pty.openpty">252<span class="sig-prename descclassname"><span class="pre">pty.</span></span><span class="sig-name descname"><span class="pre">openpty</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pty.openpty" title="Link to this definition">¶</a></dt>253<dd><p>Open a new pseudo-terminal pair, using <a class="reference internal" href="os.html#os.openpty" title="os.openpty"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.openpty()</span></code></a> if possible, or254emulation code for generic Unix systems. Return a pair of file descriptors255<code class="docutils literal notranslate"><span class="pre">(master,</span> <span class="pre">slave)</span></code>, for the master and the slave end, respectively.</p>256</dd></dl>257 258<dl class="py function">259<dt class="sig sig-object py" id="pty.spawn">260<span class="sig-prename descclassname"><span class="pre">pty.</span></span><span class="sig-name descname"><span class="pre">spawn</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">argv</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">master_read</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">stdin_read</span></span></em><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#pty.spawn" title="Link to this definition">¶</a></dt>261<dd><p>Spawn a process, and connect its controlling terminal with the current262process’s standard io. This is often used to baffle programs which insist on263reading from the controlling terminal. It is expected that the process264spawned behind the pty will eventually terminate, and when it does <em>spawn</em>265will return.</p>266<p>A loop copies STDIN of the current process to the child and data received267from the child to STDOUT of the current process. It is not signaled to the268child if STDIN of the current process closes down.</p>269<p>The functions <em>master_read</em> and <em>stdin_read</em> are passed a file descriptor270which they should read from, and they should always return a byte string. In271order to force spawn to return before the child process exits an272empty byte array should be returned to signal end of file.</p>273<p>The default implementation for both functions will read and return up to 1024274bytes each time the function is called. The <em>master_read</em> callback is passed275the pseudoterminal’s master file descriptor to read output from the child276process, and <em>stdin_read</em> is passed file descriptor 0, to read from the277parent process’s standard input.</p>278<p>Returning an empty byte string from either callback is interpreted as an279end-of-file (EOF) condition, and that callback will not be called after280that. If <em>stdin_read</em> signals EOF the controlling terminal can no longer281communicate with the parent process OR the child process. Unless the child282process will quit without any input, <em>spawn</em> will then loop forever. If283<em>master_read</em> signals EOF the same behavior results (on linux at least).</p>284<p>Return the exit status value from <a class="reference internal" href="os.html#os.waitpid" title="os.waitpid"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.waitpid()</span></code></a> on the child process.</p>285<p><a class="reference internal" href="os.html#os.waitstatus_to_exitcode" title="os.waitstatus_to_exitcode"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.waitstatus_to_exitcode()</span></code></a> can be used to convert the exit status into286an exit code.</p>287<p class="audit-hook">Raises an <a class="reference internal" href="sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">pty.spawn</span></code> with argument <code class="docutils literal notranslate"><span class="pre">argv</span></code>.</p>288<div class="versionchanged">289<p><span class="versionmodified changed">Changed in version 3.4: </span><code class="xref py py-func docutils literal notranslate"><span class="pre">spawn()</span></code> now returns the status value from <a class="reference internal" href="os.html#os.waitpid" title="os.waitpid"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.waitpid()</span></code></a>290on the child process.</p>291</div>292</dd></dl>293 294<section id="example">295<h2>Example<a class="headerlink" href="#example" title="Link to this heading">¶</a></h2>296<p>The following program acts like the Unix command <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/script(1)">script(1)</a></em>, using a297pseudo-terminal to record all input and output of a terminal session in a298“typescript”.</p>299<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">argparse</span>300<span class="kn">import</span><span class="w"> </span><span class="nn">os</span>301<span class="kn">import</span><span class="w"> </span><span class="nn">pty</span>302<span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>303<span class="kn">import</span><span class="w"> </span><span class="nn">time</span>304 305<span class="n">parser</span> <span class="o">=</span> <span class="n">argparse</span><span class="o">.</span><span class="n">ArgumentParser</span><span class="p">()</span>306<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-a&#39;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s1">&#39;append&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">)</span>307<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;-p&#39;</span><span class="p">,</span> <span class="n">dest</span><span class="o">=</span><span class="s1">&#39;use_python&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">)</span>308<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;filename&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s1">&#39;typescript&#39;</span><span class="p">)</span>309<span class="n">options</span> <span class="o">=</span> <span class="n">parser</span><span class="o">.</span><span class="n">parse_args</span><span class="p">()</span>310 311<span class="n">shell</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">executable</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">use_python</span> <span class="k">else</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;SHELL&#39;</span><span class="p">,</span> <span class="s1">&#39;sh&#39;</span><span class="p">)</span>312<span class="n">filename</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">filename</span>313<span class="n">mode</span> <span class="o">=</span> <span class="s1">&#39;ab&#39;</span> <span class="k">if</span> <span class="n">options</span><span class="o">.</span><span class="n">append</span> <span class="k">else</span> <span class="s1">&#39;wb&#39;</span>314 315<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">mode</span><span class="p">)</span> <span class="k">as</span> <span class="n">script</span><span class="p">:</span>316    <span class="k">def</span><span class="w"> </span><span class="nf">read</span><span class="p">(</span><span class="n">fd</span><span class="p">):</span>317        <span class="n">data</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="mi">1024</span><span class="p">)</span>318        <span class="n">script</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>319        <span class="k">return</span> <span class="n">data</span>320 321    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Script started, file is&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span>322    <span class="n">script</span><span class="o">.</span><span class="n">write</span><span class="p">((</span><span class="s1">&#39;Script started on </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">time</span><span class="o">.</span><span class="n">asctime</span><span class="p">())</span><span class="o">.</span><span class="n">encode</span><span class="p">())</span>323 324    <span class="n">pty</span><span class="o">.</span><span class="n">spawn</span><span class="p">(</span><span class="n">shell</span><span class="p">,</span> <span class="n">read</span><span class="p">)</span>325 326    <span class="n">script</span><span class="o">.</span><span class="n">write</span><span class="p">((</span><span class="s1">&#39;Script done on </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">time</span><span class="o">.</span><span class="n">asctime</span><span class="p">())</span><span class="o">.</span><span class="n">encode</span><span class="p">())</span>327    <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Script done, file is&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span>328</pre></div>329</div>330</section>331</section>332 333 334            <div class="clearer"></div>335          </div>336        </div>337      </div>338      <div class="sphinxsidebar" role="navigation" aria-label="Main">339        <div class="sphinxsidebarwrapper">340  <div>341    <h3><a href="../contents.html">Table of Contents</a></h3>342    <ul>343<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> — Pseudo-terminal utilities</a><ul>344<li><a class="reference internal" href="#example">Example</a></li>345</ul>346</li>347</ul>348 349  </div>350  <div>351    <h4>Previous topic</h4>352    <p class="topless"><a href="tty.html"353                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tty</span></code> — Terminal control functions</a></p>354  </div>355  <div>356    <h4>Next topic</h4>357    <p class="topless"><a href="fcntl.html"358                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">fcntl</span></code> — The <code class="docutils literal notranslate"><span class="pre">fcntl</span></code> and <code class="docutils literal notranslate"><span class="pre">ioctl</span></code> system calls</a></p>359  </div>360  <script>361    document.addEventListener('DOMContentLoaded', () => {362        const title = document.querySelector('meta[property="og:title"]').content;363        const elements = document.querySelectorAll('.improvepage');364        const pageurl = window.location.href.split('?')[0];365        elements.forEach(element => {366            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));367            url.searchParams.set('pagetitle', title);368            url.searchParams.set('pageurl', pageurl);369            url.searchParams.set('pagesource', "library/pty.rst");370            element.href = url.toString();371        });372    });373  </script>374  <div role="note" aria-label="source link">375    <h3>This page</h3>376    <ul class="this-page-menu">377      <li><a href="../bugs.html">Report a bug</a></li>378      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>379      <li>380        <a href="https://github.com/python/cpython/blob/main/Doc/library/pty.rst?plain=1"381            rel="nofollow">Show source382        </a>383      </li>384      385    </ul>386  </div>387        </div>388<div id="sidebarbutton" title="Collapse sidebar">389<span>«</span>390</div>391 392      </div>393      <div class="clearer"></div>394    </div>  395    <div class="related" role="navigation" aria-label="Related">396      <h3>Navigation</h3>397      <ul>398        <li class="right" style="margin-right: 10px">399          <a href="../genindex.html" title="General Index"400             >index</a></li>401        <li class="right" >402          <a href="../py-modindex.html" title="Python Module Index"403             >modules</a> |</li>404        <li class="right" >405          <a href="fcntl.html" title="fcntl — The fcntl and ioctl system calls"406             >next</a> |</li>407        <li class="right" >408          <a href="tty.html" title="tty — Terminal control functions"409             >previous</a> |</li>410 411          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>412          <li><a href="https://www.python.org/">Python</a> &#187;</li>413          <li class="switchers">414            <div class="language_switcher_placeholder"></div>415            <div class="version_switcher_placeholder"></div>416          </li>417          <li>418              419          </li>420    <li id="cpython-language-and-version">421      <a href="../index.html">3.15.0a6 Documentation</a> &#187;422    </li>423 424          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>425          <li class="nav-item nav-item-2"><a href="unix.html" >Unix-specific services</a> &#187;</li>426        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pty</span></code> — Pseudo-terminal utilities</a></li>427                <li class="right">428                    429 430    <div class="inline-search" role="search">431        <form class="inline-search" action="../search.html" method="get">432          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">433          <input type="submit" value="Go">434        </form>435    </div>436                     |437                </li>438            <li class="right">439<label class="theme-selector-label">440    Theme441    <select class="theme-selector" oninput="activateTheme(this.value)">442        <option value="auto" selected>Auto</option>443        <option value="light">Light</option>444        <option value="dark">Dark</option>445    </select>446</label> |</li>447            448      </ul>449    </div>  450    <div class="footer">451    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.452    <br>453    This page is licensed under the Python Software Foundation License Version 2.454    <br>455    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.456    <br>457    458      See <a href="/license.html">History and License</a> for more information.<br>459    460    461    <br>462 463    The Python Software Foundation is a non-profit corporation.464<a href="https://www.python.org/psf/donations/">Please donate.</a>465<br>466    <br>467      Last updated on Mar 10, 2026 (08:58 UTC).468    469      <a href="/bugs.html">Found a bug</a>?470    471    <br>472 473    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.474    </div>475 476  </body>477</html>