aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/rc.conf29
-rw-r--r--sh/rc-cgroup.sh.in13
2 files changed, 34 insertions, 8 deletions
diff --git a/etc/rc.conf b/etc/rc.conf
index d9ad911d..b7296d35 100644
--- a/etc/rc.conf
+++ b/etc/rc.conf
@@ -277,10 +277,33 @@ rc_tty_number=12
# Set this to YES if you want all of the processes in a service's cgroup
# killed when the service is stopped or restarted.
-# This should not be set globally because it kills all of the service's
-# child processes, and most of the time this is undesirable. Please set
-# it in /etc/conf.d/<service>.
+# Be aware that setting this to yes means all of a service's
+# child processes will be killed. Keep this in mind if you set this to
+# yes here instead of for the individual services in
+# /etc/conf.d/<service>.
# To perform this cleanup manually for a stopped service, you can
# execute cgroup_cleanup with /etc/init.d/<service> cgroup_cleanup or
# rc-service <service> cgroup_cleanup.
+# The process followed in this cleanup is the following:
+# 1. send stopsig (sigterm if it isn't set) to all processes left in the
+# cgroup immediately followed by sigcont.
+# 2. Send sighup to all processes in the cgroup if rc_send_sighup is
+# yes.
+# 3. delay for rc_timeout_stopsec seconds.
+# 4. send sigkill to all processes in the cgroup unless disabled by
+# setting rc_send_sigkill to no.
# rc_cgroup_cleanup="NO"
+
+# If this is yes, we will send sighup to the processes in the cgroup
+# immediately after stopsig and sigcont.
+#rc_send_sighup="NO"
+
+# This is the amount of time in seconds that we delay after sending sigcont
+# and optionally sighup, before we optionally send sigkill to all
+# processes in the # cgroup.
+# The default is 90 seconds.
+#rc_timeout_stopsec="90"
+
+# If this is set to no, we do not send sigkill to all processes in the
+# cgroup.
+#rc_send_sigkill="YES"
diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in
index 47a007b6..4b713594 100644
--- a/sh/rc-cgroup.sh.in
+++ b/sh/rc-cgroup.sh.in
@@ -204,10 +204,13 @@ cgroup_cleanup()
local pids
pids="$(cgroup_get_pids)"
if [ -n "${pids}" ]; then
- kill -s TERM "${pids}"
- sleep 1
- pids="$(cgroup_get_pids)"
- [ -n "${pids}" ] &&
- kill -s KILL "${pids}"
+ kill -s "${stopsig:-SIGTERM}" ${pids} 2> /dev/null
+ kill -s SIGCONT ${pids} 2> /dev/null
+ yesno "${rc_send_sighup:-no}" &&
+ kill -s SIGHUP ${pids} 2> /dev/null
+ sleep "${rc_timeout_stopsec:-90}"
+ yesno "${rc_send_sigkill:-yes}" &&
+ kill -s SIGKILL ${pids} 2> /dev/null
fi
+ eend 0
}