X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fservice.c;h=d3852c76a13644570b7d8967e90e6570c6b2cb21;hb=560d8f23811162542c1748f711ea6dce269d2720;hp=195f04a3150a4c16fd1cd7294861983193c0d410;hpb=f34277d9117cd9d858f7332eef0023e05277ce74;p=elogind.git diff --git a/src/service.c b/src/service.c index 195f04a31..d3852c76a 100644 --- a/src/service.c +++ b/src/service.c @@ -1627,7 +1627,11 @@ static void service_enter_dead(Service *s, bool success, bool allow_restart) { if (allow_restart && !s->forbid_restart && (s->restart == SERVICE_RESTART_ALWAYS || - (s->restart == SERVICE_RESTART_ON_SUCCESS && !s->failure))) { + (s->restart == SERVICE_RESTART_ON_SUCCESS && !s->failure) || + (s->restart == SERVICE_RESTART_ON_FAILURE && s->failure) || + (s->restart == SERVICE_RESTART_ON_ABORT && s->failure && + (s->main_exec_status.code == CLD_KILLED || + s->main_exec_status.code == CLD_DUMPED)))) { if ((r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch)) < 0) goto fail; @@ -2406,7 +2410,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { if (s->main_pid == pid) { s->main_pid = 0; - exec_status_exit(&s->main_exec_status, pid, code, status); + exec_status_exit(&s->main_exec_status, pid, code, status, s->exec_context.utmp_id); if (s->type != SERVICE_FORKING && s->control_command) { s->control_command->exec_status = s->main_exec_status; @@ -2483,7 +2487,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { s->control_pid = 0; if (s->control_command) { - exec_status_exit(&s->control_command->exec_status, pid, code, status); + exec_status_exit(&s->control_command->exec_status, pid, code, status, s->exec_context.utmp_id); if (s->control_command->ignore) success = true; @@ -3115,7 +3119,9 @@ DEFINE_STRING_TABLE_LOOKUP(service_state, ServiceState); static const char* const service_restart_table[_SERVICE_RESTART_MAX] = { [SERVICE_RESTART_NO] = "no", [SERVICE_RESTART_ON_SUCCESS] = "on-success", - [SERVICE_RESTART_ALWAYS] = "always", + [SERVICE_RESTART_ON_FAILURE] = "on-failure", + [SERVICE_RESTART_ON_ABORT] = "on-abort", + [SERVICE_RESTART_ALWAYS] = "always" }; DEFINE_STRING_TABLE_LOOKUP(service_restart, ServiceRestart);