ó
	æNXc           @   sV   d  Z  d d l Z d d l Z d d l m Z m Z m Z m Z d „  Z d „  Z	 d S(   s<   Substitute for the forkpty system call, to support Solaris.
iÿÿÿÿN(   t   STDIN_FILENOt   STDOUT_FILENOt   STDERR_FILENOt   CHILDc          C   s²   t  j ƒ  \ }  } |  d k  s* | d k  r9 t d ƒ ‚ n  t  j ƒ  } | t k r› t  j |  ƒ t | ƒ t  j | t ƒ t  j | t	 ƒ t  j | t
 ƒ n t  j | ƒ | |  f S(   sá  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

    i    s   os.openpty() failed(   t   ost   openptyt   OSErrort   forkR   t   closet   pty_make_controlling_ttyt   dup2R    R   R   (   t	   parent_fdt   child_fdt   pid(    (    sL   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/ptyprocess/_fork_pty.pyt   fork_pty   s    
c         C   s#  t  j |  ƒ } y- t  j d t  j t  j Bƒ } t  j | ƒ Wn+ t k
 ri } | j t j k rj ‚  qj n Xt  j	 ƒ  y9 t  j d t  j t  j Bƒ } t  j | ƒ t
 d ƒ ‚ Wn+ t k
 rÚ } | j t j k rÛ ‚  qÛ n Xt  j | t  j ƒ } t  j | ƒ t  j d t  j ƒ } t  j | ƒ d S(   s¢   This makes the pseudo-terminal the controlling tty. This should be
    more portable than the pty.fork() function. Specifically, this should
    work on Solaris. s   /dev/ttys(   OSError of errno.ENXIO should be raised.N(   R   t   ttynamet   opent   O_RDWRt   O_NOCTTYR   R   t   errnot   ENXIOt   setsidt   ExceptionPexpectt   O_WRONLY(   t   tty_fdt
   child_namet   fdt   err(    (    sL   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/ptyprocess/_fork_pty.pyR	   *   s&    


(
   t   __doc__R   R   t   ptyR    R   R   R   R   R	   (    (    (    sL   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/ptyprocess/_fork_pty.pyt   <module>   s
   "	"