summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2014-07-28 23:23:49 +0800
committerMatt Johnston <matt@ucc.asn.au>2014-07-28 23:23:49 +0800
commit45cd2fc537a7d90a9a2051e90bdafc4a3ed2e1d1 (patch)
treef9136238cf6c8f49173ed691e79989ef4e3b4ae4
parent4fa710bb188c9e02300a35f670c9ab254c79344e (diff)
downloaddropbear-45cd2fc537a7d90a9a2051e90bdafc4a3ed2e1d1.tar.gz
Make sure the check_close() handler runs when a server child process exits
-rw-r--r--common-channel.c6
-rw-r--r--session.h1
-rw-r--r--svr-chansession.c3
3 files changed, 10 insertions, 0 deletions
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))