Skip to content

Commit

Permalink
sh/rc-cgroup.sh: add openrc. prefix the cgroupv2 path
Browse files Browse the repository at this point in the history
Some services, like docker, creates and manages /sys/fs/cgroup/<service>
themselves. Avoid conflict with the openrc created cgroup path by adding
a `openrc.` prefix.

Fixes: #680
  • Loading branch information
ncopa authored and williamh committed Jan 9, 2024
1 parent 439cce4 commit 97689d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sh/rc-cgroup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cgroup_get_pids()
cgroup_pids=
cgroup_procs="$(cgroup2_find_path)"
if [ -n "${cgroup_procs}" ]; then
cgroup_procs="${cgroup_procs}/${RC_SVCNAME}/cgroup.procs"
cgroup_procs="${cgroup_procs}/openrc.${RC_SVCNAME}/cgroup.procs"
else
cgroup_procs="/sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks"
fi
Expand Down Expand Up @@ -167,7 +167,7 @@ cgroup2_remove()
local cgroup_path rc_cgroup_path
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 0
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
[ ! -d "${rc_cgroup_path}" ] ||
[ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
return 0
Expand All @@ -191,7 +191,7 @@ cgroup2_set_limits()
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 0
mountinfo -q "${cgroup_path}"|| return 0
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
[ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
[ -f "${rc_cgroup_path}"/cgroup.procs ] &&
printf 0 > "${rc_cgroup_path}"/cgroup.procs
Expand All @@ -210,7 +210,7 @@ cgroup2_kill_cgroup() {
local cgroup_path
cgroup_path="$(cgroup2_find_path)"
[ -z "${cgroup_path}" ] && return 1
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
rc_cgroup_path="${cgroup_path}/openrc.${RC_SVCNAME}"
if [ -f "${rc_cgroup_path}"/cgroup.kill ]; then
printf "%d" 1 > "${rc_cgroup_path}"/cgroup.kill
fi
Expand Down

0 comments on commit 97689d6

Please sign in to comment.