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
评论列表
文章目录