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
This commit is contained in:
Lennart Poettering
2018-06-04 11:35:25 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 8150acb160
commit ec5b1452ac
+5 -6
View File
@@ -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);