← Back
Editing: _fork_pty.cpython-38.pyc
U �ԁ^: � @ sL d Z ddlZddlZddlmZmZmZmZ ddlm Z dd� Z dd � ZdS ) z<Substitute for the forkpty system call, to support Solaris. � N)�STDIN_FILENO� STDOUT_FILENO� STDERR_FILENO�CHILD� )�PtyProcessErrorc C s~ t �� \} }| dk s|dk r$td��t �� }|tkrlt �| � t|� t �|t� t �|t � t �|t � n t �|� || fS )a� This implements a substitute for the forkpty system call. This should be more portable than the pty.fork() function. Specifically, this should work on Solaris. Modified 10.06.05 by Geoff Marshall: Implemented __fork_pty() method to resolve the issue with Python's pty.fork() not supporting Solaris, particularly ssh. Based on patch to posixmodule.c authored by Noah Spurrier:: http://mail.python.org/pipermail/python-dev/2003-May/035281.html r zos.openpty() failed)�os�openpty�OSError�forkr �close�pty_make_controlling_tty�dup2r r r )Z parent_fdZchild_fd�pid� r �6/usr/lib/python3/dist-packages/ptyprocess/_fork_pty.py�fork_pty s r c C s� t �| �}z"t �dt jt jB �}t �|� W n0 tk r\ } z|jtjkrL� W 5 d}~X Y nX t � � z*t �dt jt jB �}t �|� t d��W n0 tk r� } z|jtjkr�� W 5 d}~X Y nX t �|t j�}t �|� t �dt j�}t �|� dS )z�This makes the pseudo-terminal the controlling tty. This should be more portable than the pty.fork() function. Specifically, this should work on Solaris. z/dev/ttyNz(OSError of errno.ENXIO should be raised.)r �ttyname�open�O_RDWR�O_NOCTTYr r �errnoZENXIO�setsidr �O_WRONLY)Ztty_fdZ child_name�fd�errr r r r + s&