From: Lennart Poettering Date: Mon, 4 Jun 2018 09:35:25 +0000 (+0200) Subject: core: go to failure state if the main service process fails and RemainAfterExit=yes... X-Git-Tag: v239~158 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ec5b1452ac73e41274f9b3ca401f813fa079b9f0;p=thirdparty%2Fsystemd.git core: go to failure state if the main service process fails and RemainAfterExit=yes (#9159) Previously, we'd not care about failures that were seen earlier and remain in "exited" state. This could be triggered if the main process of a service failed while ExecStartPost= was still running, as in that case we'd not immediately act on the main process failure because we needed to wait for ExecStartPost= to finish, before acting on it. Fixes: #8929 --- diff --git a/src/core/service.c b/src/core/service.c index 068fd67be78..32fec122fc0 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1839,10 +1839,11 @@ static void service_enter_running(Service *s, ServiceResult f) { service_unwatch_control_pid(s); - if (service_good(s)) { + if (s->result != SERVICE_SUCCESS) + service_enter_signal(s, SERVICE_STOP_SIGTERM, f); + else if (service_good(s)) { - /* If there are any queued up sd_notify() - * notifications, process them now */ + /* If there are any queued up sd_notify() notifications, process them now */ if (s->notify_state == NOTIFY_RELOADING) service_enter_reload_by_notify(s); else if (s->notify_state == NOTIFY_STOPPING) @@ -1852,9 +1853,7 @@ static void service_enter_running(Service *s, ServiceResult f) { service_arm_timer(s, usec_add(UNIT(s)->active_enter_timestamp.monotonic, s->runtime_max_usec)); } - } else if (f != SERVICE_SUCCESS) - service_enter_signal(s, SERVICE_STOP_SIGTERM, f); - else if (s->remain_after_exit) + } else if (s->remain_after_exit) service_set_state(s, SERVICE_EXITED); else service_enter_stop(s, SERVICE_SUCCESS);