AlkantarClanX12

Your IP : 18.119.122.69


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/pty.cpython-310.opt-1.pyc

o

6��f]�@s�dZddlmZddlZddlZddlZddlmZmZddlmZmZm	Z	gd�Z
dZdZdZ
dZd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zeefdd�Zeefdd�ZdS)zPseudo terminal utilities.�)�selectN)�close�waitpid)�setraw�	tcgetattr�	tcsetattr)�openpty�fork�spawn��c	Cs<zt��WSttfyYnwt�\}}t|�}||fS)zdopenpty() -> (master_fd, slave_fd)
    Open a pty master/slave pair, using os.openpty() if possible.)�osr�AttributeError�OSError�_open_terminal�
slave_open)�	master_fd�
slave_name�slave_fd�r�*/opt/alt/python310/lib64/python3.10/pty.pyrs
�
rc	CsHzt��\}}Wn
ttfyYt�Swt�|�}t�|�||fS)z�master_open() -> (master_fd, slave_name)
    Open a pty master and return the fd, and the filename of the slave end.
    Deprecated, use openpty() instead.)r
rrr�ttynamerr)rrrrrr�master_open&s�

rc
CsddD]+}dD]&}d||}z	t�|tj�}Wn	ty Yqw|d||fSqtd��)z1Open pty master and return (master_fd, tty_name).ZpqrstuvwxyzPQRSTZ0123456789abcdefz/dev/ptyz/dev/ttyzout of pty devices)r
�open�O_RDWRr)�x�yZpty_name�fdrrrr6s��rcCsnt�|tj�}z
ddlm}m}Wnty|YSwz|||d�|||d�W|Sty6Y|Sw)z�slave_open(tty_name) -> slave_fd
    Open the pty slave and acquire the controlling terminal, returning
    opened filedescriptor.
    Deprecated, use openpty() instead.r)�ioctl�I_PUSHZptemZldterm)r
rrZfcntlrr�ImportErrorr)Ztty_name�resultrrrrrrBs���rc	Cs�zt��\}}WnttfyYnw|tkr.z	t��W||fSty-Y||fSw||fSt�\}}t��}|tkrvt��t�|�t�	|t
�t�	|t�t�	|t�|tkrct�|�t�
t�t�tj�}t�|�||fSt�|�||fS)zdfork() -> (pid, master_fd)
    Fork and make the child a session leader with a controlling terminal.)r
�forkptyrr�CHILD�setsidrr	r�dup2�STDIN_FILENO�
STDOUT_FILENO�
STDERR_FILENOrrr)�pidrrrZtmp_fdrrrr	Ts:�
��




�r	cCs(|rt�||�}||d�}|sdSdS)z#Write all the data to a descriptor.N)r
�write)r�data�nrrr�_writen|s�r-cCst�|d�S)zDefault read function.i)r
�read)rrrr�_read�sr/cCs�|tg}|rHt|gg�\}}}||vr/z||�}Wnty$d}Ynw|s)dSt�t|�t|vrD|t�}|s?|�t�nt||�|sdSdS)z�Parent copy loop.
    Copies
            pty master -> standard output   (master_read)
            standard input -> pty master    (stdin_read)�N)r&rrr
r*r'�remover-)r�master_read�
stdin_readZfdsZrfdsZ_wfdsZ_xfdsr+rrr�_copy�s$�
�r4c
Cs�t|�td�kr|f}t�d|�t�\}}|tkr%tj|dg|�R�ztt�}t	t�d}Wnt
jy=d}Ynwzt|||�W|rOt
tt
j|�n|rZt
tt
j|�wwt|�t|d�dS)zCreate a spawned process.�z	pty.spawnrTFr)�type�sys�auditr	r#r
�execlprr&r�tty�errorr4rZ	TCSAFLUSHrr)�argvr2r3r)r�modeZrestorerrrr
�s.
����r
)�__doc__rr
r7r:rrrrr�__all__r&r'r(r#rrrrr	r-r/r4r
rrrr�<module>s*(