diff options
-rw-r--r-- | sh/cgroup-release-agent.sh.in | 4 | ||||
-rw-r--r-- | sh/rc-cgroup.sh.in | 12 | ||||
-rw-r--r-- | sh/runscript.sh.in | 4 |
3 files changed, 13 insertions, 7 deletions
diff --git a/sh/cgroup-release-agent.sh.in b/sh/cgroup-release-agent.sh.in index c3174fee..d6dd1e1e 100644 --- a/sh/cgroup-release-agent.sh.in +++ b/sh/cgroup-release-agent.sh.in @@ -5,6 +5,6 @@ cgroup=/sys/fs/cgroup/openrc PATH=/bin:/usr/bin:/sbin:/usr/sbin -if [ -d ${cgroup}/$1 ]; then - rmdir ${cgroup}/$1 +if [ -d ${cgroup}/"$1" ]; then + rmdir ${cgroup}/"$1" fi diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 81fc7d86..afcbb031 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -70,15 +70,17 @@ cgroup_set_values() return 0 } -cgroup_set_limits() +cgroup_add_service() { - openrc_cgroup=/sys/fs/cgroup/openrc - if [ -d "$openrc_cgroup" ]; then - cgroup="$openrc_cgroup/$RC_SVCNAME" + if [ -d "$1" ]; then + cgroup="$1/$RC_SVCNAME" mkdir -p "$cgroup" [ -f "$cgroup/tasks" ] && echo 0 > "$cgroup/tasks" fi +} +cgroup_set_limits() +{ local blkio="${rc_cgroup_blkio:-$RC_CGROUP_BLKIO}" [ -n "$blkio" ] && cgroup_set_values blkio "$blkio" @@ -115,7 +117,7 @@ cgroup_cleanup() cgroup_get_pids || { eend 0 "finished" ; return 0 ; } sleep 1 done - done + done 2>/dev/null done cgroup_get_pids || { eend 0 "finished" ; return 0; } kill -9 $pids diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 58e8eacf..a1ed9c68 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -209,6 +209,10 @@ sourcex -e "@SYSCONFDIR@/rc.conf" [ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT} # Apply cgroups settings if defined +if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]; then + cgroup_add_service /sys/fs/cgroup/openrc + cgroup_add_service /sys/fs/cgroup/systemd/system +fi [ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && \ cgroup_set_limits |