diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2018-03-11 21:40:57 -0500 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2018-03-11 21:41:01 -0500 |
commit | 61905bfcf560219939c902dbb8fe9bc5088a42cf (patch) | |
tree | a4e202917e39c83beff26a9bb34c135f7d88c431 /sh/rc-cgroup.sh.in | |
parent | 3e68013631765e00eddf118bc24e38254e7f6d64 (diff) |
Clean up cgroups v2 code
Remove the IFS manipulation and simplify the loop that processes the
settings.
Diffstat (limited to 'sh/rc-cgroup.sh.in')
-rw-r--r-- | sh/rc-cgroup.sh.in | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in index 5bc7db54..d4b68ada 100644 --- a/sh/rc-cgroup.sh.in +++ b/sh/rc-cgroup.sh.in @@ -184,18 +184,17 @@ cgroup2_set_limits() cgroup_path="$(cgroup2_find_path)" [ -d "${cgroup_path}" ] || return 0 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}" - local OIFS="$IFS" - IFS=" -" [ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}" - printf "%d" 0 > "${rc_cgroup_path}/cgroup.procs" - echo "${rc_cgroup_settings}" | while IFS="$OIFS" read -r key value; do - [ -z "${key}" ] || [ -z "${value}" ] && continue - [ ! -e "${rc_cgroup_path}/${key}" ] && continue - veinfo "${RC_SVCNAME}: cgroups: ${key} ${value}" - printf "%s" "${value}" > "${rc_cgroup_path}/${key}" + [ -f "${rc_cgroup_path}"/cgroup.procs ] && + printf 0 > "${rc_cgroup_path}"/cgroup.procs + [ -z "${rc_cgroup_settings}" ] && return 0 + echo "${rc_cgroup_settings}" | while read -r key value; do + [ -z "${key}" ] && continue + [ -z "${value}" ] && continue + [ ! -f "${rc_cgroup_path}/${key}" ] && continue + veinfo "${RC_SVCNAME}: cgroups: setting ${key} to ${value}" + printf "%s\n" "${value}" > "${rc_cgroup_path}/${key}" done - IFS="$OIFS" return 0 } |