Fix progress print-out ordering bug, and run HOOK_SVC_START only on success
Only run HOOK_SVC_START on successful start, and *after* having printed
the result of the started service, otherwise any print-outs from plugins
or tasks we start may overwrite the started service's progress.
@@ -311,8 +311,6 @@ static int service_start(svc_t *svc)
close(svc->stdin_fd);
#endif
- plugin_run_hook(HOOK_SVC_START, (void *)(uintptr_t)pid);
-
if (SVC_TYPE_RUN == svc->type) {
result = WEXITSTATUS(complete(svc->cmd, pid));
if (!svc_clean_bootstrap(svc)) {
@@ -322,8 +320,17 @@ static int service_start(svc_t *svc)
}
sigprocmask(SIG_SETMASK, &omask, NULL);
+ print_result(result);
+
+ /*
+ * Only run hook on successful start, and *after* having printed
+ * the result, otherwise any hook tasks may overwrite it and the
+ * result would be like double "[ OK ]" but only one service.
+ */
+ if (!result)
+ plugin_run_hook(HOOK_SVC_START, (void *)(uintptr_t)pid);
- return print_result(result);
+ return result;
}
/**
