ó m”þfc@s¶dZddlmZddlZddlZdddgZdZdZd ZdZd „Z d „Z d „Z d „Z d„Z d„Zd„Zeed„Zeed„ZdS(sPseudo terminal utilities.iÿÿÿÿ(tselectNtopenptytforktspawniiicCsMytjƒSWnttfk r'nXtƒ\}}t|ƒ}||fS(sdopenpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible.(tosRtAttributeErrortOSErrort_open_terminalt slave_open(t master_fdt slave_nametslave_fd((s/usr/lib64/python2.7/pty.pyRs cCs]ytjƒ\}}Wnttfk r/n'Xtj|ƒ}tj|ƒ||fStƒS(s›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.(RRRRtttynametcloseR(R R R ((s/usr/lib64/python2.7/pty.pyt master_open!s  cCsôyddl}Wntk r#nOXy"|jtjddƒ\}}Wntk rg}tj|‚nX||fSxodD]g}x^dD]V}d||}ytj|tjƒ}Wntjk rÌq†nX|d||fSWqyWtjd ‚dS( slOpen pty master and return (master_fd, tty_name). SGI and generic BSD version, for when openpty() fails.iÿÿÿÿNi¶itpqrstuvwxyzPQRSTt0123456789abcdefs/dev/ptys/dev/ttysout of pty devices(tsgit ImportErrort_getptyRtO_RDWRtIOErrorterrortopen(Rttty_nameR tmsgtxtytpty_nametfd((s/usr/lib64/python2.7/pty.pyR1s$ "   cCs€tj|tjƒ}yddlm}m}Wntk rC|SXy$|||dƒ|||dƒWntk r{nX|S(s©slave_open(tty_name) -> slave_fd Open the pty slave and acquire the controlling terminal, returning opened filedescriptor. Deprecated, use openpty() instead.iÿÿÿÿ(tioctltI_PUSHtptemtldterm(RRRtfcntlRRRR(RtresultRR((s/usr/lib64/python2.7/pty.pyRHs  cCs:ytjƒ\}}Wnttfk r/n<X|tkraytjƒWqatk r]qaXn||fStƒ\}}tjƒ}|tkr#tjƒtj|ƒtj |t ƒtj |t ƒtj |t ƒ|t krõtj|ƒntj tjt ƒtjƒ}tj|ƒn tj|ƒ||fS(sdfork() -> (pid, master_fd) Fork and make the child a session leader with a controlling terminal.(RtforkptyRRtCHILDtsetsidRRR tdup2t STDIN_FILENOt STDOUT_FILENOt STDERR_FILENORR R(tpidRR R ttmp_fd((s/usr/lib64/python2.7/pty.pyRZs0         cCs3x,|dkr.tj||ƒ}||}qWdS(s#Write all the data to a descriptor.tN(Rtwrite(Rtdatatn((s/usr/lib64/python2.7/pty.pyt_writen‚scCstj|dƒS(sDefault read function.i(Rtread(R((s/usr/lib64/python2.7/pty.pyt_readˆscCs·|tg}x¤tr²t|ggƒ\}}}||krq||ƒ}|s^|j|ƒqqtjt|ƒnt|kr|tƒ}|sŸ|jtƒq¯t||ƒqqWdS(sParent copy loop. Copies pty master -> standard output (master_read) standard input -> pty master (stdin_read)N(R(tTrueRtremoveRR.R)R1(R t master_readt stdin_readtfdstrfdstwfdstxfdsR/((s/usr/lib64/python2.7/pty.pyt_copyŒs      cCs÷t|ƒtdƒkr$|f}ntƒ\}}|tkrVtj|d|Œny&tjtƒ}tjtƒd}Wntj k r˜d}nXyt |||ƒWn6t t fk rå|rætj ttj|ƒqænXtj|ƒdS(sCreate a spawned process.R-iiN(ttypeRR%Rtexeclptttyt tcgetattrR(tsetrawRR<RRt tcsetattrt TCSAFLUSHR (targvR6R7R+R tmodetrestore((s/usr/lib64/python2.7/pty.pyR¡s"     (t__doc__RRR?t__all__R(R)R*R%RRRRRR1R3R<R(((s/usr/lib64/python2.7/pty.pyts"      (