diff options
author | Thomas Kluyver <thomas@kluyver.me.uk> | 2018-02-06 15:08:08 +0000 |
---|---|---|
committer | Thomas Kluyver <thomas@kluyver.me.uk> | 2018-02-06 15:09:10 +0000 |
commit | 78ca448e14babf7aa5eaeeb50dbfa30efe43badf (patch) | |
tree | eb71411aad6916171284f5a96fd334262670cdbf | |
parent | 28e82cda5056df20ec55995ea7fe66abd346f6bb (diff) | |
download | pexpect-78ca448e14babf7aa5eaeeb50dbfa30efe43badf.tar.gz |
Ensure spawn.closed gets set, improve sigwinch_passthrough example
Closes gh-465
-rw-r--r-- | pexpect/pty_spawn.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pexpect/pty_spawn.py b/pexpect/pty_spawn.py index 4afda6a..70cba00 100644 --- a/pexpect/pty_spawn.py +++ b/pexpect/pty_spawn.py @@ -322,6 +322,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 @@ -729,9 +730,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 self.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() |