From 0eb11e7db68598f20456500191a527407755ddea Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Tue, 7 Dec 2021 13:24:47 -0600 Subject: [PATCH] killprocs: add kill_delay setting This allows containers using OpenRC based services to be configured to allow open tcp connections to be closed before they are shut down. This fixes #476. --- conf.d/killprocs | 5 +++++ init.d/killprocs.in | 2 ++ z | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 z diff --git a/conf.d/killprocs b/conf.d/killprocs index 76a2bc9c..a515b782 100644 --- a/conf.d/killprocs +++ b/conf.d/killprocs @@ -4,3 +4,8 @@ # The setting is called killall5_opts because the options here are meant # to be identical to those you could pass to killall5. killall5_opts="" + +# If you need to delay after each kill attempt during shutdown, set the amount +# of time you need to delay here. This gets passed directly to sleep in +# the shell. +# kill_delay=0 diff --git a/init.d/killprocs.in b/init.d/killprocs.in index fcf1364d..3903cbdf 100644 --- a/init.d/killprocs.in +++ b/init.d/killprocs.in @@ -20,8 +20,10 @@ start() { ebegin "Terminating remaining processes" kill_all 15 ${killall5_opts} + sleep ${kill_delay:-0} eend 0 ebegin "Killing remaining processes" + sleep ${kill_delay:-0} kill_all 9 ${killall5_opts} eend 0 } diff --git a/z b/z new file mode 100644 index 00000000..09858302 --- /dev/null +++ b/z @@ -0,0 +1,27 @@ +diff --git a/conf.d/killprocs b/conf.d/killprocs +index 76a2bc9c..1c93b89d 100644 +--- a/conf.d/killprocs ++++ b/conf.d/killprocs +@@ -4,3 +4,7 @@ + # The setting is called killall5_opts because the options here are meant + # to be identical to those you could pass to killall5. + killall5_opts="" ++ ++# If you need to call sleep after each kill attempt during shutdown, set ++# the amount of time you need to sleep here. ++# sleep_time=0 +diff --git a/init.d/killprocs.in b/init.d/killprocs.in +index fcf1364d..7b96a7a7 100644 +--- a/init.d/killprocs.in ++++ b/init.d/killprocs.in +@@ -20,8 +20,10 @@ start() + { + ebegin "Terminating remaining processes" + kill_all 15 ${killall5_opts} ++ sleep ${sleep_time:-0} + eend 0 + ebegin "Killing remaining processes" ++ sleep ${sleep_time:-0} + kill_all 9 ${killall5_opts} + eend 0 + }