Skip to content

Instantly share code, notes, and snippets.

@kuoe0 kuoe0/
Last active Jan 1, 2016

What would you like to do?
#! /usr/bin/env python
import pty
import os
import select
def mkpty():
master1, slave = pty.openpty()
slaveName1 = os.ttyname(slave)
master2, slave = pty.openpty()
slaveName2 = os.ttyname(slave)
print '\nslave device names: ', slaveName1, slaveName2
return master1, master2
if __name__ == "__main__":
master1, master2 = mkpty()
while True:
rl, wl, el =[master1,master2], [], [], 1)
for master in rl:
data =, 128)
print "read %d data." % len(data)
if master==master1:
os.write(master2, data)
os.write(master1, data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.