Add housekeeping functions to clean up unused cgroups

This should not be needed, but for some reason we don't get events when
early processes exit, so we end up with lingering cgroups.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2025-12-15 22:04:32 +01:00
1 parent e756d6f8ac
commit dd36116a97
3 files changed
+87 -1

No files matched your search

+9
View File
@@ -29,6 +29,7 @@
#include <termios.h>
#include "finit.h"
#include "cgroup.h"
#include "cond.h"
#include "conf.h"
#include "log.h"
@@ -191,6 +192,10 @@ static void sm_check_bootstrap(void *work)
dbg("Clean up all bootstrap-only tasks/services ...");
svc_prune_bootstrap();
/* Clean up empty cgroups from bootstrap tasks (e.g., udevadm, coldplug) */
dbg("Pruning empty cgroups from bootstrap ...");
cgroup_prune();
/* All services/tasks/etc. in configure runlevel have started */
dbg("Running svc up hooks ...");
plugin_run_hooks(HOOK_SVC_UP);
@@ -402,6 +407,10 @@ restart:
dbg("All services have been stopped, calling runlevel change hooks ...");
plugin_run_hooks(HOOK_RUNLEVEL_CHANGE); /* Reconfigure HW/VLANs/etc here */
/* Clean up empty cgroups from previous runlevel */
dbg("Pruning empty cgroups from previous runlevel ...");
cgroup_prune();
dbg("Starting services new to this runlevel ...");
sm.in_reload = 0;
service_step_all(SVC_TYPE_ANY);