- (dtucker) [channels.c configure.ac serverloop.c] Bug #1102: Around AIX
   4.3.3 ML3 or so, the AIX pty layer starting passing zero-length writes
   on the pty slave as zero-length reads on the pty master, which sshd
   interprets as the descriptor closing.  Since most things don't do zero
   length writes this rarely matters, but occasionally it happens, and when
   it does the SSH pty session appears to hang, so we add a special case for
   this condition.  ok djm@
diff --git a/channels.c b/channels.c
index 2fa997e..239e9dd 100644
--- a/channels.c
+++ b/channels.c
@@ -1415,10 +1415,15 @@
 
 	if (c->rfd != -1 &&
 	    FD_ISSET(c->rfd, readset)) {
+		errno = 0;
 		len = read(c->rfd, buf, sizeof(buf));
 		if (len < 0 && (errno == EINTR || errno == EAGAIN))
 			return 1;
+#ifndef PTY_ZEROREAD
 		if (len <= 0) {
+#else
+		if (len < 0 || (len == 0 && errno != 0)) {
+#endif
 			debug2("channel %d: read<=0 rfd %d len %d",
 			    c->self, c->rfd, len);
 			if (c->type != SSH_CHANNEL_OPEN) {