o
    È·e:	  ã                   @   sL   d Z ddlZddlZddlmZmZmZmZ ddlm	Z	 dd„ Z
dd	„ ZdS )
z<Substitute for the forkpty system call, to support Solaris.
é    N)ÚSTDIN_FILENOÚSTDOUT_FILENOÚSTDERR_FILENOÚCHILDé   )ÚPtyProcessErrorc                  C   s„   t  ¡ \} }| dk s|dk rtdƒ‚t  ¡ }|tkr9t  | ¡ t|ƒ t  |t¡ t  |t	¡ t  |t
¡ || fS t  |¡ || fS )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   zos.openpty() failed)ÚosÚopenptyÚOSErrorÚforkr   ÚcloseÚpty_make_controlling_ttyÚdup2r   r   r   )Ú	parent_fdÚchild_fdÚpid© r   úK/var/www/ideatree/venv/lib/python3.10/site-packages/ptyprocess/_fork_pty.pyÚfork_pty	   s   

þr   c              
   C   sö   t  | ¡}zt  dt jt jB ¡}t  |¡ W n ty/ } z|jtjkr%‚ W Y d}~nd}~ww t  	¡  zt  dt jt jB ¡}t  |¡ t
dƒ‚ ty` } z|jtjkrV‚ W Y d}~nd}~ww t  |t j¡}t  |¡ t  dt j¡}t  |¡ dS )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
   ÚerrnoÚENXIOÚsetsidr   ÚO_WRONLY)Útty_fdÚ
child_nameÚfdÚerrr   r   r   r   +   s2   
ÿ€ÿ
ÿ€ÿ
r   )Ú__doc__r   r   Úptyr   r   r   r   Úutilr   r   r   r   r   r   r   Ú<module>   s    "