diff options
author | Matt Johnston <matt@ucc.asn.au> | 2007-02-09 10:43:16 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2007-02-09 10:43:16 +0000 |
commit | f5ad5c15531a8288222aeafa5b28f30298b3497f (patch) | |
tree | 63a0e1f29db3403d6b86d82486629a1a9ba5f870 /common-session.c | |
parent | cda7af7ca2fe9fb8d848e7891a528e63531a4e8d (diff) |
Improve behaviour when flushing out after a process has exited.
--HG--
branch : channel-fix
extra : convert_revision : e73ee8f7ae404a9355685c30828a0ad4524031bc
Diffstat (limited to 'common-session.c')
-rw-r--r-- | common-session.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/common-session.c b/common-session.c index a16d1f9..6e1abf3 100644 --- a/common-session.c +++ b/common-session.c @@ -61,6 +61,12 @@ void common_session_init(int sock, char* remotehost) { ses.connecttimeout = 0; + if (pipe(ses.signal_pipe) < 0) { + dropbear_exit("signal pipe failed"); + } + setnonblocking(ses.signal_pipe[0]); + setnonblocking(ses.signal_pipe[1]); + kexfirstinitialise(); /* initialise the kex state */ ses.writepayload = buf_new(MAX_TRANS_PAYLOAD_LEN); @@ -108,7 +114,6 @@ void common_session_init(int sock, char* remotehost) { ses.allowprivport = 0; - TRACE(("leave session_init")) } @@ -132,6 +137,10 @@ void session_loop(void(*loophandler)()) { FD_SET(ses.sock, &writefd); } } + + /* We get woken up when signal handlers write to this pipe. + SIGCHLD in svr-chansession is the only one currently. */ + FD_SET(ses.signal_pipe[0], &readfd); /* set up for channels which require reading/writing */ if (ses.dataallowed) { @@ -155,6 +164,14 @@ void session_loop(void(*loophandler)()) { FD_ZERO(&writefd); FD_ZERO(&readfd); } + + /* We'll just empty out the pipe if required. We don't do + any thing with the data, since the pipe's purpose is purely to + wake up the select() above. */ + if (FD_ISSET(ses.signal_pipe[0], &readfd)) { + char x; + while (read(ses.signal_pipe[0], &x, 1) > 0) {} + } /* check for auth timeout, rekeying required etc */ checktimeouts(); |