diff --git a/common-channel.c b/common-channel.c index 967c937..63a42fb 100644 --- a/common-channel.c +++ b/common-channel.c @@ -258,6 +258,12 @@ void channelio(fd_set *readfds, fd_set *writefds) { writechannel(channel, channel->errfd, channel->extrabuf); do_check_close = 1; } + + if (ses.channel_signal_pending) { + /* SIGCHLD can change channel state for server sessions */ + do_check_close = 1; + ses.channel_signal_pending = 0; + } /* handle any channel closing etc */ if (do_check_close) { diff --git a/session.h b/session.h index 3a0e87a..b09fa44 100644 --- a/session.h +++ b/session.h @@ -187,6 +187,7 @@ struct sshsession { unsigned int chansize; /* the number of Channel*s allocated for channels */ unsigned int chancount; /* the number of Channel*s in use */ const struct ChanType **chantypes; /* The valid channel types */ + int channel_signal_pending; /* Flag set by sigchld handler */ /* TCP priority level for the main "port 22" tcp socket */ enum dropbear_prio socket_prio; diff --git a/svr-chansession.c b/svr-chansession.c index 4b45294..2a99362 100644 --- a/svr-chansession.c +++ b/svr-chansession.c @@ -89,6 +89,9 @@ static void sesssigchild_handler(int UNUSED(dummy)) { const int saved_errno = errno; + /* Make channel handling code look for closed channels */ + ses.channel_signal_pending = 1; + TRACE(("enter sigchld handler")) while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { TRACE(("sigchld handler: pid %d", pid))