From 4e6b9514d576101768f0a66a2139727b8cd1075a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 7 Apr 2021 13:55:07 +0200 Subject: [PATCH] cgroup: check return value from fnwrite(), found by Coverity Scan We check it everywhere else, and a log message for failing to move PID 1 to the init cgroup is useful as well. Signed-off-by: Joachim Wiberg --- src/cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cgroup.c b/src/cgroup.c index 312ea942..371f0511 100644 --- a/src/cgroup.c +++ b/src/cgroup.c @@ -296,7 +296,8 @@ void cgroup_init(uev_ctx_t *ctx) group_init(FINIT_CGPATH "/system", 0, "cpu.weight:9800"); /* Move ourselves to init (best effort, otherwise run in 'root' group */ - fnwrite("1", FINIT_CGPATH "/init/cgroup.procs"); + if (fnwrite("1", FINIT_CGPATH "/init/cgroup.procs")) + _pe("Failed moving PID 1 to cgroup ", FINIT_CGPATH "/init"); /* prepare cgroup.events watcher */ fd = iwatch_init(&iw_cgroup);