summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2018-02-10 12:03:33 +0000
committerGitHub <noreply@github.com>2018-02-10 12:03:33 +0000
commitc4d1566c3da5029479b9fd10c033ef6757f6c4d7 (patch)
tree7607bba98a5ee153cef236f82e10c4c9d4404eaf
parent6ba1fbb133426a376b788d217a3b31953c3d2b30 (diff)
parent5da9fc0874eea9ff2948353e68185f2cbb9c0b98 (diff)
downloadpexpect-c4d1566c3da5029479b9fd10c033ef6757f6c4d7.tar.gz
Merge pull request #466 from takluyver/i465
Ensure spawn.closed gets set, improve sigwinch_passthrough example
-rw-r--r--pexpect/pty_spawn.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py
index 9e012e7..c1a835b 100644
--- a/pexpect/pty_spawn.py
+++ b/pexpect/pty_spawn.py
@@ -320,6 +320,7 @@ class spawn(SpawnBase):
self.ptyproc.close(force=force)
self.isalive() # Update exit status from ptyproc
self.child_fd = -1
+ self.closed = True
def isatty(self):
'''This returns True if the file descriptor is open and connected to a
@@ -727,9 +728,10 @@ class spawn(SpawnBase):
s = struct.pack("HHHH", 0, 0, 0, 0)
a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
termios.TIOCGWINSZ , s))
- global p
- p.setwinsize(a[0],a[1])
- # Note this 'p' global and used in sigwinch_passthrough.
+ if not p.closed:
+ p.setwinsize(a[0],a[1])
+
+ # Note this 'p' is global and used in sigwinch_passthrough.
p = pexpect.spawn('/bin/bash')
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
p.interact()