Skip to content

Instantly share code, notes, and snippets.

@jquast
Created March 17, 2014 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jquast/9594459 to your computer and use it in GitHub Desktop.
Save jquast/9594459 to your computer and use it in GitHub Desktop.
>>> import pty, os, termios
>>> master, slave = pty.openpty()
>>> master, slave
(3, 5)
>>> termios.tcgetattr(master)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
termios.error: (22, 'Invalid argument')
>>> termios.tcgetattr(slave)
[9474, 6149, 189, 35387, 0, 13, ['\x03', '\x1c', '\x7f', '\x15', '\x04', '\x00', '\x00', '\x00', '\x11', '\x13', '\x1a', '\x19', '\x12', '\x0f', '\x17', '\x16', '\x00', '\x00', '\x00']]
>>> os.isatty(master)
False
>>> os.isatty(slave)
True
>>> os.ttyname(slave)
'/dev/pts/1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment