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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-07 13:55:07 +02:00
parent 3b495d7518
commit 4e6b9514d5
+2 -1
View File
@@ -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);