From b50ac18bbdf10ce41bcbce6aabbae8651c8baeca Mon Sep 17 00:00:00 2001 From: Aukansh Date: Sun, 13 Sep 2026 11:01:38 +0800 Subject: [PATCH] Enable cgroup controllers for child cgroup creation Enable CPU, memory, and PID controllers in parent cgroup before creating a child cgroup. Fix daemon.warn procd: failed adding instance cgroup for sysntpd: I/O error Signed-off-by: Aukansh --- service/instance.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/service/instance.c b/service/instance.c index 61fbfaa..8d28438 100644 --- a/service/instance.c +++ b/service/instance.c @@ -636,6 +636,16 @@ instance_add_cgroup(const char *service, const char *instance) if (stat("/sys/fs/cgroup/cgroup.subtree_control", &sb)) return 0; + /* Enable controllers in the parent cgroup before creating the child */ + fd = open("/sys/fs/cgroup/cgroup.subtree_control", O_WRONLY); + if (fd >= 0) { + if (write(fd, "+cpu +memory +pids", 18) < 0) { + /* Ignore errors; controllers may already be enabled + * or not available. */ + } + close(fd); + } + ret = snprintf(cgnamebuf, sizeof(cgnamebuf), "%s/%s/%s", CGROUP_BASEDIR, service, instance); if (ret >= sizeof(cgnamebuf))