From 15e7d4b64c237243657742cb50fead1062bbb92e Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Fri, 29 Sep 2000 10:57:35 +1100 Subject: [PATCH] - (djm) Fix SSH2 not terminating until all background tasks done problem. --- ChangeLog | 3 +++ serverloop.c | 5 ++--- session.c | 12 +++++++++++- session.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1467f9370..8aaa68f02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +20000929 + - (djm) Fix SSH2 not terminating until all background tasks done problem. + 20000926 - (djm) Update X11-askpass to 1.0.2 in RPM spec file - (djm) Define _REENTRANT to pickup strtok_r() on HP/UX diff --git a/serverloop.c b/serverloop.c index be9edfafc..50e89aee8 100644 --- a/serverloop.c +++ b/serverloop.c @@ -110,7 +110,6 @@ sigchld_handler2(int sig) int save_errno = errno; debug("Received SIGCHLD."); child_terminated = 1; - child_has_selected = 0; errno = save_errno; } @@ -675,10 +674,10 @@ server_loop2(void) session_close_by_pid(pid, status); child_terminated = 0; signal(SIGCHLD, sigchld_handler2); + if (used_sessions() == 0) + break; } channel_after_select(&readset, &writeset); - if (child_terminated && child_has_selected) - break; process_input(&readset); process_output(&writeset); } diff --git a/session.c b/session.c index 296dfadec..ca12a4f73 100644 --- a/session.c +++ b/session.c @@ -150,6 +150,8 @@ char *original_command = NULL; /* data */ #define MAX_SESSIONS 10 Session sessions[MAX_SESSIONS]; +static int num_used_sessions; + #ifdef WITH_AIXAUTHENTICATE /* AIX's lastlogin message, set in auth1.c */ char *aixloginmsg; @@ -1422,6 +1424,7 @@ session_new(void) sessions[i].used = 0; sessions[i].self = i; } + num_used_sessions = 0; did_init = 1; } for(i = 0; i < MAX_SESSIONS; i++) { @@ -1440,7 +1443,8 @@ session_new(void) s->auth_proto = NULL; s->used = 1; s->pw = NULL; - debug("session_new: session %d", i); + num_used_sessions++; + debug("session_new: session %d (%d used)", i, num_used_sessions); return s; } } @@ -1853,6 +1857,7 @@ session_close(Session *s) session_pty_cleanup(s); session_free(s); session_proctitle(s); + num_used_sessions--; } void @@ -1898,6 +1903,11 @@ session_close_by_channel(int id, void *arg) } } +int used_sessions(void) +{ + return(num_used_sessions); +} + char * session_tty_list(void) { diff --git a/session.h b/session.h index bce99f77c..69d3b7dd4 100644 --- a/session.h +++ b/session.h @@ -33,5 +33,6 @@ int session_open(int id); void session_input_channel_req(int id, void *arg); void session_close_by_pid(pid_t pid, int status); void session_close_by_channel(int id, void *arg); +int used_sessions(void); #endif