From 594476c4fcd4dc20844ba521a8c1b940da944f63 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 13 Dec 2017 17:32:52 +0100 Subject: [PATCH] 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 --- src/service.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/service.c b/src/service.c index aa4be3b7..c1b67430 100644 --- a/src/service.c +++ b/src/service.c @@ -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; } /**