aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorAidan Harris <me@aidanharr.is>2021-09-15 07:11:01 +0000
committerWilliam Hubbs <w.d.hubbs@gmail.com>2021-10-15 22:10:37 -0500
commiteaa42da9a62b55a26c7b866d4082c554a764b95f (patch)
treecbf514532174d1d9add4f5e3067057c4a30872b9 /sh
parentcd4bbdcd62be460dabc232f6bd52e3b2c347408a (diff)
Use cgroup.kill in cgroup_cleanup when possible
The old code is moved to a cgroup_fallback_cleanup function and only called if cgroup2_kill fails. This fixes #454.
Diffstat (limited to 'sh')
-rw-r--r--sh/rc-cgroup.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/sh/rc-cgroup.sh b/sh/rc-cgroup.sh
index 2abe659f..fd61ebd2 100644
--- a/sh/rc-cgroup.sh
+++ b/sh/rc-cgroup.sh
@@ -206,10 +206,19 @@ cgroup2_set_limits()
return 0
}
-cgroup_cleanup()
-{
- cgroup_running || return 0
- ebegin "Starting cgroups cleanup"
+cgroup2_kill_cgroup() {
+ local cgroup_path
+ cgroup_path="$(cgroup2_find_path)"
+ [ -z "${cgroup_path}" ] && return 1
+ rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
+ if [ -f "${rc_cgroup_path}"/cgroup.kill ]; then
+ printf "%d" 1 > "${rc_cgroup_path}"/cgroup.kill
+ fi
+ return
+}
+
+cgroup_fallback_cleanup() {
+ ebegin "Starting fallback cgroups cleanup"
local loops=0
cgroup_get_pids
if [ -n "${cgroup_pids}" ]; then
@@ -229,6 +238,14 @@ cgroup_cleanup()
kill -s KILL ${cgroup_pids} 2> /dev/null
fi
fi
+ eend $?
+}
+
+cgroup_cleanup()
+{
+ cgroup_running || return 0
+ ebegin "Starting cgroups cleanup"
+ cgroup2_kill_cgroup || cgroup_fallback_cleanup
cgroup2_remove
cgroup_get_pids
[ -z "${cgroup_pids}" ]