aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-09-11 13:26:58 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2014-09-11 13:26:58 -0500
commit50658449bd46f1a53b8eb11d34f6eefdd1ceba9c (patch)
tree522eccff58d8d1b1d8f746d8894aa166a703c5eb /sh
parentde60ffeebe93ffdc09c1dda51e04f29485d96cdb (diff)
Use exception-based approach for cgroup/ulimit setup
Note from William Hubbs: I spoke with Roy about this, and he pointed out that user-defined functions may need the limits applied, so it is better to go with a method that uses exceptions to determine which functions apply the limits. X-Gentoo-Bug: 522408 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=522408
Diffstat (limited to 'sh')
-rw-r--r--sh/runscript.sh.in34
1 files changed, 22 insertions, 12 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index d4c7c60c..b89c4607 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -209,19 +209,29 @@ unset _conf_d
# Load any system overrides
sourcex -e "@SYSCONFDIR@/rc.conf"
-# Apply any ulimit defined
-[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT}
-
-# Apply cgroups settings if defined
-if [ "$1" = "start" ] ; then
- 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
+for _cmd; do
+ if [ "$_cmd" != status -a "$_cmd" != describe ]; then
+ # Apply any ulimit defined
+ [ -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
+ if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
+ eerror "No permission to apply cgroup settings"
+ break
+ fi
+ 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
+ break
fi
- [ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && \
- cgroup_set_limits
-fi
-
+done
+
# Load our script
sourcex "$RC_SERVICE"