diff --git a/paramiko/channel.py b/paramiko/channel.py index 97c7df5..c4e8540 100644 --- a/paramiko/channel.py +++ b/paramiko/channel.py @@ -996,7 +996,7 @@ class Channel (object): self.in_buffer_cv.notifyAll() self.in_stderr_buffer_cv.notifyAll() if self.pipe is not None: - self.pipe.set() + self.pipe.set_forever() finally: self.lock.release() self._log(DEBUG, 'EOF received') @@ -1022,6 +1022,8 @@ class Channel (object): self.in_buffer_cv.notifyAll() self.in_stderr_buffer_cv.notifyAll() self.out_buffer_cv.notifyAll() + if self.pipe is not None: + self.pipe.set_forever() def _send_eof(self): # you are holding the lock. diff --git a/paramiko/pipe.py b/paramiko/pipe.py index 8c53987..cc28f43 100644 --- a/paramiko/pipe.py +++ b/paramiko/pipe.py @@ -36,6 +36,7 @@ class PosixPipe (object): def __init__ (self): self._rfd, self._wfd = os.pipe() self._set = False + self._forever = False def close (self): os.close(self._rfd) @@ -45,7 +46,7 @@ class PosixPipe (object): return self._rfd def clear (self): - if not self._set: + if not self._set or self._forever: return os.read(self._rfd, 1) self._set = False @@ -55,6 +56,10 @@ class PosixPipe (object): return self._set = True os.write(self._wfd, '*') + + def set_forever (self): + self._forever = True + self.set() class WindowsPipe (object): @@ -74,6 +79,7 @@ class WindowsPipe (object): self._wsock, addr = serv.accept() serv.close() self._set = False + self._forever = False def close (self): self._rsock.close() @@ -83,7 +89,7 @@ class WindowsPipe (object): return self._rsock.fileno() def clear (self): - if not self._set: + if not self._set or self._forever: return self._rsock.recv(1) self._set = False @@ -93,3 +99,7 @@ class WindowsPipe (object): return self._set = True self._wsock.send('*') + + def set_forever (self): + self._forever = True + self.set()