run stanzas are never caught in service_monitor()

A run stanza blocks operation by calling waitpid(), so it will never be
caught by the service_monitor() function.  Hence, we need to clean up
any bootsrap calls after waitpid(), or at least perform a manual state
change.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-09-04 16:02:23 +02:00
parent 29822ef0f7
commit 9e7e92b4b7
+5 -1
View File
@@ -44,6 +44,7 @@
#define RESPAWN_MAX 10 /* Prevent endless respawn of faulty services. */
static void svc_set_state(svc_t *svc, svc_state_t new);
/**
* service_enabled - Should the service run?
@@ -311,7 +312,10 @@ static int service_start(svc_t *svc)
if (SVC_TYPE_RUN == svc->type) {
result = WEXITSTATUS(complete(svc->cmd, pid));
svc->pid = 0;
if (!svc_clean_bootstrap(svc)) {
svc->pid = 0;
svc_set_state(svc, SVC_STOPPING_STATE);
}
}
sigprocmask(SIG_SETMASK, &omask, NULL);