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.
This commit is contained in:
parent
cd4bbdcd62
commit
eaa42da9a6
@ -288,7 +288,9 @@ rc_tty_number=12
|
|||||||
# To perform this cleanup manually for a stopped service, you can
|
# To perform this cleanup manually for a stopped service, you can
|
||||||
# execute cgroup_cleanup with /etc/init.d/<service> cgroup_cleanup or
|
# execute cgroup_cleanup with /etc/init.d/<service> cgroup_cleanup or
|
||||||
# rc-service <service> cgroup_cleanup.
|
# rc-service <service> cgroup_cleanup.
|
||||||
# The process followed in this cleanup is the following:
|
# If the kernel includes support for cgroup2's cgroup.kill, this is used
|
||||||
|
# to reliably teardown the cgroup.
|
||||||
|
# If this fails, the process followed in this cleanup is the following:
|
||||||
# 1. send stopsig (sigterm if it isn't set) to all processes left in the
|
# 1. send stopsig (sigterm if it isn't set) to all processes left in the
|
||||||
# cgroup immediately followed by sigcont.
|
# cgroup immediately followed by sigcont.
|
||||||
# 2. Send sighup to all processes in the cgroup if rc_send_sighup is
|
# 2. Send sighup to all processes in the cgroup if rc_send_sighup is
|
||||||
|
@ -206,10 +206,19 @@ cgroup2_set_limits()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup_cleanup()
|
cgroup2_kill_cgroup() {
|
||||||
{
|
local cgroup_path
|
||||||
cgroup_running || return 0
|
cgroup_path="$(cgroup2_find_path)"
|
||||||
ebegin "Starting cgroups cleanup"
|
[ -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
|
local loops=0
|
||||||
cgroup_get_pids
|
cgroup_get_pids
|
||||||
if [ -n "${cgroup_pids}" ]; then
|
if [ -n "${cgroup_pids}" ]; then
|
||||||
@ -229,6 +238,14 @@ cgroup_cleanup()
|
|||||||
kill -s KILL ${cgroup_pids} 2> /dev/null
|
kill -s KILL ${cgroup_pids} 2> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
cgroup_cleanup()
|
||||||
|
{
|
||||||
|
cgroup_running || return 0
|
||||||
|
ebegin "Starting cgroups cleanup"
|
||||||
|
cgroup2_kill_cgroup || cgroup_fallback_cleanup
|
||||||
cgroup2_remove
|
cgroup2_remove
|
||||||
cgroup_get_pids
|
cgroup_get_pids
|
||||||
[ -z "${cgroup_pids}" ]
|
[ -z "${cgroup_pids}" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user