Skip to content

Commit df50964

Browse files
committed
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 )
1 parent 3a660dc commit df50964

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

channels.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191

9292
#ifdef WIN32_FIXME
9393
#define isatty(a) WSHELPisatty(a)
94+
#define SFD_TYPE_CONSOLE 4
9495
#endif
9596

9697

@@ -1686,8 +1687,10 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset)
16861687
errno = 0;
16871688
len = read(c->rfd, buf, sizeof(buf));
16881689
#ifdef WIN32_FIXME
1689-
if (len == 0)
1690+
if (len == 0) {
1691+
if ( get_sfd_type(c->rfd) == SFD_TYPE_CONSOLE)
16901692
return 1; // in Win32 console read, there may be no data, but is ok
1693+
}
16911694
#endif
16921695
if (len < 0 && (errno == EINTR ||
16931696
((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))

0 commit comments

Comments
 (0)