Add a missing client-detached hook when the server shuts down, and do

not exit until jobs started from run-shell/if-shell have finished (add a
job flags member and a flag to indicate other jobs). GitHub issue 1245.
This commit is contained in:
nicm
2018-03-08 08:09:10 +00:00
parent 85c48aafff
commit 19f3a5c612
8 changed files with 22 additions and 7 deletions

View File

@ -244,6 +244,7 @@ server_loop(void)
{
struct client *c;
u_int items;
struct job *job;
do {
items = cmdq_next(NULL);
@ -276,6 +277,11 @@ server_loop(void)
if (!TAILQ_EMPTY(&clients))
return (0);
LIST_FOREACH(job, &all_jobs, entry) {
if ((~job->flags & JOB_NOWAIT) && job->state == JOB_RUNNING)
return (0);
}
return (1);
}
@ -291,8 +297,11 @@ server_send_exit(void)
TAILQ_FOREACH_SAFE(c, &clients, entry, c1) {
if (c->flags & CLIENT_SUSPENDED)
server_client_lost(c);
else
else {
if (c->flags & CLIENT_ATTACHED)
notify_client("client-detached", c);
proc_send(c->peer, MSG_SHUTDOWN, -1, NULL, 0);
}
c->session = NULL;
}