From df50964dfc545b3d93d831ceaef0f2f284eb9f46 Mon Sep 17 00:00:00 2001 From: quamrulmina Date: Fri, 6 Nov 2015 12:05:09 -0600 Subject: [PATCH] Fix regression issue of ssh not exiting after sftp client ends Add smarter logic when reading 0 bytes is ok (only when tty console read ) --- channels.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/channels.c b/channels.c index 19049ec..03a6c9d 100644 --- a/channels.c +++ b/channels.c @@ -91,6 +91,7 @@ #ifdef WIN32_FIXME #define isatty(a) WSHELPisatty(a) +#define SFD_TYPE_CONSOLE 4 #endif @@ -1686,8 +1687,10 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset) errno = 0; len = read(c->rfd, buf, sizeof(buf)); #ifdef WIN32_FIXME - if (len == 0) + if (len == 0) { + if ( get_sfd_type(c->rfd) == SFD_TYPE_CONSOLE) return 1; // in Win32 console read, there may be no data, but is ok + } #endif if (len < 0 && (errno == EINTR || ((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))