ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/pty.cpython-34.pyo

�
e f��@s�dZddlmZddlZddlZdddgZdZdZdZdZd	d�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zeedd�Zeedd�ZdS)zPseudo terminal utilities.�)�selectN�openpty�fork�spawn��cCsNytj�SWnttfk
r(YnXt�\}}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/python34/lib64/python3.4/pty.pyrscCs^ytj�\}}Wnttfk
r0Yn'Xtj|�}tj|�||fSt�S)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.)rrr	r
�ttyname�closer)r
rrrrr�master_open!s

rc
Cs�xmdD]e}x\dD]T}d||}ytj|tj�}Wntk
rXwYnX|d||fSWqWtd��dS)z1Open pty master and return (master_fd, tty_name).ZpqrstuvwxyzPQRSTZ0123456789abcdefz/dev/ptyz/dev/ttyzout of pty devicesN)r�open�O_RDWRr
)�x�yZpty_name�fdrrrr1s


rcCs�tj|tj�}yddlm}m}Wntk
rG|SYnXy$|||d�|||d�Wntk
r�YnX|S)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)rrrZfcntlrr�ImportErrorr
)Ztty_name�resultrrrrrr=s
	
rcCs<ytj�\}}Wnttfk
r0Yn=X|tkrcytj�Wqctk
r_YqcXn||fSt�\}}tj�}|tkr%tj�tj|�tj	|t
�tj	|t�tj	|t�|tkr�tj|�ntj
tjt�tj�}tj|�n
tj|�||fS)zdfork() -> (pid, master_fd)
    Fork and make the child a session leader with a controlling terminal.)r�forkptyr	r
�CHILD�setsidrrr�dup2�STDIN_FILENO�
STDOUT_FILENO�
STDERR_FILENOrrr)�pidrr
rZtmp_fdrrrrOs0




cCs3x,|r.tj||�}||d�}qWdS)z#Write all the data to a descriptor.N)r�write)r�data�nrrr�_writenws	r)cCstj|d�S)zDefault read function.i)r�read)rrrr�_read}sr+cCs�|tg}x�t|gg�\}}}||krk||�}|sX|j|�qktjt|�nt|kr|t�}|s�|jt�q�t||�qqWdS)z�Parent copy loop.
    Copies
            pty master -> standard output   (master_read)
            standard input -> pty master    (stdin_read)N)r"r�removerr&r#r))r
�master_read�
stdin_readZfdsZrfdsZwfdsZxfdsr'rrr�_copy�sr/cCst|�td�kr$|f}nt�\}}|tkrVtj|d|�ny&tjt�}tjt�d}Wntj	k
r�d}YnXyt
|||�Wn1tk
r�|r�tjttj
|�nYnXtj|�tj|d�dS)zCreate a spawned process.�rr)�typerrr�execlp�ttyZ	tcgetattrr"Zsetraw�errorr/r
Z	tcsetattrZ	TCSAFLUSHr�waitpid)�argvr-r.r%r
�modeZrestorerrrr�s$



)�__doc__rrr3�__all__r"r#r$rrrrrrr)r+r/rrrrr�<module>s"(

Zerion Mini Shell 1.0