pty - Pseudo terminal utilities.
| 💼 Use Case | ⚙️ Command | 📝 Description |
|---|---|---|
| Acquire a PTY pair | pty.openpty() | Returns (master_fd, slave_fd) — two file descriptors for the master and slave sides of a new pseudo-terminal. |
| Fork with controlling terminal | pty.fork() | Returns (pid, master_fd) — forks a child process that becomes a session leader with the new terminal as its controlling terminal. |
| Spawn a process in a PTY | pty.spawn(['/bin/bash']) | Creates a new process connected to a pseudo-terminal; the child's standard I/O is tied to the terminal, and the parent reads/writes through the master fd. Blocks until the child exits. |
The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.
fork() -> (pid, master_fd) — Fork and make the child a session leader with a controlling terminal.openpty() -> (master_fd, slave_fd) — Open a pty master/slave pair, using os.openpty() if possible.spawn(argv, master_read=<function _read at 0x7f9feecc0c10>, stdin_read=<function _read at 0x7f9feecc0c10>) — Create a spawned process.__all__ = ['openpty', 'fork', 'spawn']
/usr/lib/python3.10/pty.py
Generated by phpman v4.10.0-7-g98e9fd5 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-09-01 16:53 @216.73.216.239
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)