|
1 | | -"""Substitute for the forkpty system call, to support Solaris. |
| 1 | +""" |
| 2 | +Provides an alternative PTY forking mechanism. |
| 3 | +
|
| 4 | +This implementation serves as a substitute for Python's standard `pty.fork()` |
| 5 | +functionality, especially on platforms where `os.login_tty()` is unavailable |
| 6 | +in the Python build (e.g., some AIX configurations) or where the standard |
| 7 | +implementation is problematic (e.g., historically on Solaris). |
2 | 8 | """ |
3 | 9 | import os |
4 | 10 | import errno |
|
7 | 13 | from .util import PtyProcessError |
8 | 14 |
|
9 | 15 | def fork_pty(): |
10 | | - '''This implements a substitute for the forkpty system call. This |
11 | | - should be more portable than the pty.fork() function. Specifically, |
12 | | - this should work on Solaris. |
13 | | -
|
14 | | - Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to |
15 | | - resolve the issue with Python's pty.fork() not supporting Solaris, |
16 | | - particularly ssh. Based on patch to posixmodule.c authored by Noah |
17 | | - Spurrier:: |
18 | | -
|
| 16 | + '''This implements a substitute for the functionality of pty.fork(), |
| 17 | + aiming for greater portability, especially on systems where Python's |
| 18 | + os.login_tty() is unavailable or pty.fork() is problematic. |
| 19 | +
|
| 20 | + It is designed to work on: |
| 21 | + - Solaris systems (addressing historical issues with Python's pty.fork()). |
| 22 | + - AIX systems where os.login_tty() might not be compiled into Python. |
| 23 | + - Other Unix-like systems that might lack a functional os.login_tty(). |
| 24 | +
|
| 25 | + The core logic for establishing a new session and making the pseudo-terminal |
| 26 | + the controlling terminal is handled herein, similar to the operations |
| 27 | + typically performed by login_tty(). |
| 28 | +
|
| 29 | + Historical Context (Original Solaris solution by Geoff Marshall, 10.06.05): |
| 30 | + The method was initially implemented to resolve issues with Python's |
| 31 | + pty.fork() on Solaris, particularly for applications like ssh. It was |
| 32 | + inspired by a patch to Python's posixmodule.c authored by Noah Spurrier: |
19 | 33 | http://mail.python.org/pipermail/python-dev/2003-May/035281.html |
20 | | -
|
| 34 | + This approach has been generalized to cover other platforms or scenarios |
| 35 | + where os.login_tty() is not available. |
21 | 36 | ''' |
22 | 37 |
|
23 | 38 | parent_fd, child_fd = os.openpty() |
|
0 commit comments