# HG changeset patch # User Matt Johnston # Date 1406561029 -28800 # Node ID 36eacc322e00924e511810c519bf5a3f05898cdd # Parent 356a25a108a3338b58f22a6c5b03336a10cd2bbd Make sure the check_close() handler runs when a server child process exits diff -r 356a25a108a3 -r 36eacc322e00 common-channel.c --- a/common-channel.c Mon Jul 28 22:59:16 2014 +0800 +++ b/common-channel.c Mon Jul 28 23:23:49 2014 +0800 @@ -258,6 +258,12 @@ 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 -r 356a25a108a3 -r 36eacc322e00 session.h --- a/session.h Mon Jul 28 22:59:16 2014 +0800 +++ b/session.h Mon Jul 28 23:23:49 2014 +0800 @@ -187,6 +187,7 @@ 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 -r 356a25a108a3 -r 36eacc322e00 svr-chansession.c --- a/svr-chansession.c Mon Jul 28 22:59:16 2014 +0800 +++ b/svr-chansession.c Mon Jul 28 23:23:49 2014 +0800 @@ -89,6 +89,9 @@ 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))