summaryrefslogtreecommitdiff
path: root/sh/runscript.sh.in
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2011-11-19 18:15:46 -0600
committerWilliam Hubbs <williamh@gentoo.org>2011-11-20 14:07:46 -0600
commitd8bbeb184f462199582fa265c9b681288884ecd9 (patch)
tree69f41c7c2bf83eaeddad57e177505b1c2abacca4 /sh/runscript.sh.in
parent453d13296d84472e6317472c2b27015b3ca612c4 (diff)
downloadopenrc-d8bbeb184f462199582fa265c9b681288884ecd9.tar.gz
openrc-d8bbeb184f462199582fa265c9b681288884ecd9.tar.bz2
openrc-d8bbeb184f462199582fa265c9b681288884ecd9.tar.xz
CGroups: create the openrc cgroup hierarchy
Openrc will create a cgroup hierarchy called openrc which will have all services it starts and all subsystems attached to it. If you need other groups/hierarchies, please use libcgroup.
Diffstat (limited to 'sh/runscript.sh.in')
-rw-r--r--sh/runscript.sh.in23
1 files changed, 13 insertions, 10 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index 706a1f7..4032cb8 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -148,6 +148,19 @@ start()
service_inactive && _inactive=true
mark_service_inactive
fi
+ if [ "$RC_UNAME" = Linux ]; then
+ local cgroup=/sys/fs/cgroup/openrc
+ local svc_cgroup=${cgroup}/${RC_SVCNAME}
+ if mountinfo -q ${cgroup}; then
+ mkdir ${svc_cgroup}
+ for f in cpuset.cpus cpuset.mems; do
+ if [ -f ${cgroup}/${f} ]; then
+ cp ${cgroup}/${f} ${svc_cgroup}
+ fi
+ done
+ echo $$ > ${svc_cgroup}/tasks
+ fi
+ fi
eval start-stop-daemon --start \
--exec $command \
${procname:+--name} $procname \
@@ -189,16 +202,6 @@ fi
# Load any system overrides
sourcex -e "@SYSCONFDIR@/rc.conf"
-# Attach to CGroup - dir existing is enough for us
-if [ -d /sys/fs/cgroup -a -n "${rc_cgroup}" ]; then
- if [ -d /sys/fs/cgroup/${rc_cgroup} ]; then
- # attach self to cgroup - any children of this process will inherit this
- echo $$ > /sys/fs/cgroup/${rc_cgroup}/tasks
- else
- eerror "Control group /sys/fs/cgroup/${rc_cgroup} does not exist."
- fi
-fi
-
# Apply any ulimit defined
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT}