cgroups: only run cgroup setup when starting a service

Status call should not set limits as it requires root permissions,
also this is not safe, as current process may reach limitation.

Solution is to set limits and move process to service cgroup only
on start.

X-GENTOO-BUG: 500364
X-GENTOO-BUG-URL: https://bugs.gentoo.org/show_bug.cgi?id=500364
This commit is contained in:
Alexander V Vershilov 2014-02-16 04:27:52 +04:00 committed by William Hubbs
parent f265ddde97
commit 1a44be0f16

View File

@ -215,12 +215,14 @@ if yesno "${rc_verbose:-$RC_VERBOSE}"; then
fi
# 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
fi
[ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && \
cgroup_set_limits
fi
# Load our script
sourcex "$RC_SERVICE"