From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 76357138332 for ; Mon, 12 Mar 2018 02:43:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 770EFE088C; Mon, 12 Mar 2018 02:43:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 56377E088C for ; Mon, 12 Mar 2018 02:43:03 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 81070335C50 for ; Mon, 12 Mar 2018 02:43:02 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EB003245 for ; Mon, 12 Mar 2018 02:43:00 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1520822461.61905bfcf560219939c902dbb8fe9bc5088a42cf.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: sh/ X-VCS-Repository: proj/openrc X-VCS-Files: sh/rc-cgroup.sh.in X-VCS-Directories: sh/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 61905bfcf560219939c902dbb8fe9bc5088a42cf X-VCS-Branch: master Date: Mon, 12 Mar 2018 02:43:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d97d33e0-3db1-4fa2-994a-2526ee736ae9 X-Archives-Hash: 247b63590b52569ef947f65efe31414a commit: 61905bfcf560219939c902dbb8fe9bc5088a42cf Author: William Hubbs gmail com> AuthorDate: Mon Mar 12 02:40:57 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Mar 12 02:41:01 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=61905bfc Clean up cgroups v2 code Remove the IFS manipulation and simplify the loop that processes the settings. sh/rc-cgroup.sh.in | 19 +++++++++---------- 1 file 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 }