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.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-12-13 17:58:48 +01:00
parent 9c423dfca4
commit 594476c4fc
+10 -3
View File
@@ -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);
return 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 result;
}
/**