Skip to content

Commit eea58c8

Browse files
committed
openrc-run.sh: extract _setup_cgroup function and replace break with return
Fixes: #1002
1 parent e5dd540 commit eea58c8

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

sh/openrc-run.sh.in

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -289,27 +289,27 @@ if yesno "${rc_verbose:-$RC_VERBOSE}"; then
289289
export EINFO_VERBOSE
290290
fi
291291

292-
case $1 in
293-
status|describe) ;;
294-
*)
295-
# Apply any ulimit(s) defined
296-
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && apply_ulimits ${rc_ulimit:-$RC_ULIMIT}
297-
292+
_setup_cgroup() {
298293
# Apply cgroups settings if defined
299294
if [ "$(command -v cgroup_add_service)" = "cgroup_add_service" ]; then
300-
if grep -qs /sys/fs/cgroup /proc/1/mountinfo
301-
then
302-
if [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]; then
303-
eerror "No permission to apply cgroup settings"
304-
break
305-
fi
295+
if grep -qs /sys/fs/cgroup /proc/1/mountinfo && [ -d /sys/fs/cgroup ] && ! [ -w /sys/fs/cgroup ]; then
296+
eerror "No permission to apply cgroup settings"
297+
return
306298
fi
307299
cgroup_add_service
308300
fi
309301

310302
[ "$(command -v cgroup_set_limits)" = "cgroup_set_limits" ] && cgroup_set_limits
311303
[ "$(command -v cgroup2_set_limits)" = "cgroup2_set_limits" ] && cgroup2_set_limits
312-
;;
304+
}
305+
306+
case $1 in
307+
status|describe) ;;
308+
*)
309+
# Apply any ulimit(s) defined
310+
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && apply_ulimits ${rc_ulimit:-$RC_ULIMIT}
311+
_setup_cgroup
312+
;;
313313
esac
314314

315315
eval "printf '%s\n' $required_dirs" | while read _d; do

0 commit comments

Comments
 (0)