1
0
mirror of https://github.com/clearml/dropbear synced 2025-04-10 15:35:41 +00:00

Make sure the check_close() handler runs when a server child process exits

This commit is contained in:
Matt Johnston 2014-07-28 23:23:49 +08:00
parent 393ca2a290
commit 0e7409c7ff
3 changed files with 10 additions and 0 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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))