summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjquast <contact@jeffquast.com>2014-06-01 14:25:27 -0700
committerjquast <contact@jeffquast.com>2014-06-01 14:25:27 -0700
commit052483f1d136e8e2694547da2635fa715252dad7 (patch)
tree46d25d97672217171eee96371a90f36424f90372
parent2d9f7840633960dd08a5766305b2df273330dee4 (diff)
downloadpexpect-issue-44-solaris-support.tar.gz
allow setwinsize() to failissue-44-solaris-support
-rw-r--r--pexpect/__init__.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/pexpect/__init__.py b/pexpect/__init__.py
index d2ee885..53fbef1 100644
--- a/pexpect/__init__.py
+++ b/pexpect/__init__.py
@@ -652,7 +652,7 @@ class spawn(object):
try:
self.setecho(self.echo)
except (IOError, OSError):
- # Linux, etc. cannot set from child.
+ # cannot setecho from child.
pass
if self.ignore_sighup:
@@ -666,14 +666,20 @@ class spawn(object):
os.execvpe(self.command, self.args, self.env)
- # Parent
- self.setwinsize(24, 80)
+ # Parent.
+ try:
+ self.setwinsize(24, 80)
+ except OSError:
+ # cannot setwinsize() from master, ignore
+ pass
+
if not self.echo:
try:
self.setecho(self.echo)
except OSError:
- # Solaris, etc. cannot set echo from master
+ # cannot setecho() from master, ignore
pass
+
self.terminated = False
self.closed = False
@@ -1760,7 +1766,13 @@ class spawn(object):
TIOCSWINSZ = getattr(termios, 'TIOCSWINSZ', -2146929561)
# Note, assume ws_xpixel and ws_ypixel are zero.
s = struct.pack('HHHH', rows, cols, 0, 0)
- fcntl.ioctl(self.fileno(), TIOCSWINSZ, s)
+ msg_nosupport = 'setwinsize() may not be called on this platform.'
+ try:
+ fcntl.ioctl(self.fileno(), TIOCSWINSZ, s)
+ except IOError as err:
+ if err.args == (22, 'Invalid argument'):
+ raise OSError(err.args[0], ('%s: %s' % (err.args[1], msg_nosupport)),)
+ raise
def interact(self, escape_character=chr(29),
input_filter=None, output_filter=None):