
    'g:	                     H    S r SSKrSSKrSSKJrJrJrJr  SSKJ	r	  S r
S rg)z<Substitute for the forkpty system call, to support Solaris.
    N)STDIN_FILENOSTDOUT_FILENOSTDERR_FILENOCHILD   )PtyProcessErrorc                     [         R                  " 5       u  pU S:  d  US:  a  [        S5      e[         R                  " 5       nU[        :X  au  [         R
                  " U 5        [        U5        [         R                  " U[        5        [         R                  " U[        5        [         R                  " U[        5        X 4$ [         R
                  " U5        X 4$ )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pids      6/usr/lib/python3/dist-packages/ptyprocess/_fork_pty.pyfork_ptyr   	   s     **,I1}1+,,
'')C
e|
 *
,'
-(
-( > 	>    c                 h   [         R                  " U 5      n [         R                  " S[         R                  [         R                  -  5      n[         R
                  " U5        [         R                  " 5          [         R                  " S[         R                  [         R                  -  5      n[         R
                  " U5        [        S5      e! [         a)  nUR                  [        R                  :w  a  e  SnANSnAff = f! [         a)  nUR                  [        R                  :w  a  e  SnAOSnAff = f[         R                  " U[         R                  5      n[         R
                  " U5        [         R                  " S[         R                  5      n[         R
                  " U5        g)zThis 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errs       r   r   r   +   s   
 F#J
WWZR[[!89

 IIKWWZR[[!89
HII  99# $  99# $
 
RYY	'BHHRL 
R[[	)BHHRLs1   AC :AD 
DC??D
D:D55D:)__doc__r
   r   ptyr   r   r   r   utilr   r   r    r   r   <module>r(      s$    	  C C ! D#r   