Mercurial > dropbear
diff svr-chansession.c @ 419:b2f81110c80b channel-fix
propagate from branch 'au.asn.ucc.matt.dropbear' (head 924b731b50d4147eed8e9382c98a2573259a6cad)
to branch 'au.asn.ucc.matt.dropbear.channel-fix' (head e73ee8f7ae404a9355685c30828a0ad4524031bc)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 11 Feb 2007 09:55:00 +0000 |
parents | a01c0c8e543a |
children | b2b67cfcd66e |
line wrap: on
line diff
--- a/svr-chansession.c Sun Feb 11 08:50:21 2007 +0000 +++ b/svr-chansession.c Sun Feb 11 09:55:00 2007 +0000 @@ -59,7 +59,6 @@ struct ChanSess * chansess); static void send_msg_chansess_exitsignal(struct Channel * channel, struct ChanSess * chansess); -static int sesscheckclose(struct Channel *channel); static void get_termmodes(struct ChanSess *chansess); @@ -68,7 +67,7 @@ static int sesscheckclose(struct Channel *channel) { struct ChanSess *chansess = (struct ChanSess*)channel->typedata; - return chansess->exit.exitpid >= 0; + return chansess->exit.exitpid != -1; } /* Handler for childs exiting, store the state for return to the client */ @@ -121,9 +120,21 @@ /* we use this to determine how pid exited */ exit->exitsignal = -1; } + + /* Make sure that the main select() loop wakes up */ + while (1) { + /* EAGAIN means the pipe's full, so don't need to write anything */ + /* isserver is just a random byte to write */ + if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1 || errno == EAGAIN) { + break; + } + if (errno == EINTR) { + continue; + } + dropbear_exit("error writing signal pipe"); + } } - sa_chld.sa_handler = sesssigchild_handler; sa_chld.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa_chld, NULL); @@ -245,16 +256,17 @@ unsigned int i; struct logininfo *li; + TRACE(("enter closechansess")) + chansess = (struct ChanSess*)channel->typedata; - send_exitsignalstatus(channel); - - TRACE(("enter closechansess")) if (chansess == NULL) { TRACE(("leave closechansess: chansess == NULL")) return; } + send_exitsignalstatus(channel); + m_free(chansess->cmd); m_free(chansess->term);