Merge pull request #31592 from YHNdnzj/exit-cgroup-notify

core/service: two fixes for ExitType=cgroup
This commit is contained in:
Lennart Poettering
2024-03-06 18:38:51 +01:00
committed by GitHub

View File

@@ -3604,8 +3604,10 @@ static void service_notify_cgroup_empty_event(Unit *u) {
break;
}
if (s->exit_type == SERVICE_EXIT_CGROUP && main_pid_good(s) <= 0)
service_enter_start_post(s);
if (s->exit_type == SERVICE_EXIT_CGROUP && main_pid_good(s) <= 0) {
service_enter_stop_post(s, SERVICE_SUCCESS);
break;
}
_fallthrough_;
case SERVICE_START_POST:
@@ -3877,11 +3879,13 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
default:
assert_not_reached();
}
} else if (s->exit_type == SERVICE_EXIT_CGROUP && s->state == SERVICE_START)
} else if (s->exit_type == SERVICE_EXIT_CGROUP && s->state == SERVICE_START &&
!IN_SET(s->type, SERVICE_NOTIFY, SERVICE_NOTIFY_RELOAD, SERVICE_DBUS))
/* If a main process exits very quickly, this function might be executed
* before service_dispatch_exec_io(). Since this function disabled IO events
* to monitor the main process above, we need to update the state here too.
* Let's consider the process is successfully launched and exited. */
* Let's consider the process is successfully launched and exited, but
* only when we're not expecting a readiness notification or dbus name. */
service_enter_start_post(s);
}