summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authornicm <nicm>2018-03-08 08:09:10 +0000
committernicm <nicm>2018-03-08 08:09:10 +0000
commit19f3a5c6120c5d845eb942e67413c03c0c008a87 (patch)
treefbd4fb03833b499bfa23d77394ba5b6365e00a01 /server.c
parent85c48aafffd4e520eea2e598ea199e7b16f787cc (diff)
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.
Diffstat (limited to 'server.c')
-rw-r--r--server.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/server.c b/server.c
index b1d3312a..5d321ccb 100644
--- a/server.c
+++ b/server.c
@@ -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;
}