process.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:black_zone 作者: zh-explorer 项目源码 文件源码
def _handles(stdin, stdout, stderr):
        master = None

        if stdout is PTY:
            # Normally we could just use subprocess.PIPE and be happy.
            # Unfortunately, this results in undesired behavior when
            # printf() and similar functions buffer data instead of
            # sending it directly.
            #
            # By opening a PTY for STDOUT, the libc routines will not
            # buffer any data on STDOUT.
            master, slave = pty.openpty()

            # By making STDOUT a PTY, the OS will attempt to interpret
            # terminal control codes.  We don't want this, we want all
            # input passed exactly and perfectly to the process.
            tty.setraw(master)
            tty.setraw(slave)

            # Pick one side of the pty to pass to the child
            stdout = slave

        return stdin, stdout, stderr, master
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号