Raises an EnvironmentError from openpty() if it fails.
"""
- import array, pty, termios
+ import array, fcntl, pty, select, termios
test_string = 2 * "blah blah blah\n"
test_string = _unicode_decode(test_string,
encoding='utf_8', errors='strict')
master_file = os.fdopen(master_fd, 'rb')
slave_file = os.fdopen(slave_fd, 'wb')
+ # Non-blocking mode is required for Darwin kernel.
+ fcntl.fcntl(master_fd, fcntl.F_SETFL,
+ fcntl.fcntl(master_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+
# Disable post-processing of output since otherwise weird
# things like \n -> \r\n transformations may occur.
mode = termios.tcgetattr(slave_fd)
eof = False
data = []
+ iwtd = [master_file]
+ owtd = []
+ ewtd = []
while not eof:
+ events = select.select(iwtd, owtd, ewtd)
+ if not events[0]:
+ eof = True
+ break
+
buf = array.array('B')
try:
buf.fromfile(master_file, 1024)