diff options
author | jquast <contact@jeffquast.com> | 2014-03-16 22:48:03 -0700 |
---|---|---|
committer | jquast <contact@jeffquast.com> | 2014-03-16 22:48:03 -0700 |
commit | e89e197a83a9f77b865a3e4b72b4b42713089066 (patch) | |
tree | 41595d120d1abd3335a0a9c8edf255fc8955550b | |
parent | 3f2ecd9264e9d8987016c33dcff22e230d31f96f (diff) | |
download | pexpect-solaris-workarounds.tar.gz |
default values of sendeof and sendintr for bad platformssolaris-workarounds
handle termios.error exception.
this is just allowing more tests to pass on sunos5,
otherwise a bit of a fork bomb may occur.
-rw-r--r-- | pexpect/__init__.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/pexpect/__init__.py b/pexpect/__init__.py index 1b77d33..ac5d0e2 100644 --- a/pexpect/__init__.py +++ b/pexpect/__init__.py @@ -1090,11 +1090,19 @@ class spawn(object): # os.write(self.child_fd, '%c' % 4) #finally: # restore state # termios.tcsetattr(fd, termios.TCSADRAIN, old) + + # for platforms without VEOF, assume CTRL-D + char = 4 if hasattr(termios, 'VEOF'): - char = ord(termios.tcgetattr(self.child_fd)[6][termios.VEOF]) - else: - # platform does not define VEOF so assume CTRL-D - char = 4 + try: + state = termios.tcgetattr(self.child_fd) + char = ord(state[6][termios.VEOF]) + except termios.error as e: + char = 4 + #sys.stderr.write('\ntermios.error: %r' % (e,)) + #sys.stderr.write('\nself.child_fd: %r' % (self.child_fd,)) + #sys.stderr.write('\nisatty: %r' % (self.isatty())) + #raise self.send(self._chr(char)) def sendintr(self): @@ -1102,11 +1110,18 @@ class spawn(object): '''This sends a SIGINT to the child. It does not require the SIGINT to be the first character on a line. ''' + # for platforms without VINTR assume CTRL-C + char = 3 if hasattr(termios, 'VINTR'): - char = ord(termios.tcgetattr(self.child_fd)[6][termios.VINTR]) - else: - # platform does not define VINTR so assume CTRL-C - char = 3 + try: + state = termios.tcgetattr(self.child_fd) + char = ord(state[6][termios.VINTR]) + except termios.error as e: + char = 3 + #sys.stderr.write('\ntermios.error: %r' % (e,)) + #sys.stderr.write('\nself.child_fd: %r' % (self.child_fd,)) + #sys.stderr.write('\nisatty: %r' % (self.isatty())) + #raise self.send(self._chr(char)) def eof(self): |