From 57444cae3eb030a76261857d9d117f971cda0bd8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 18 May 2015 12:34:45 +0300 Subject: [PATCH] killproc: retry when --waitfortime was specified so services like ldap (using killproc --waitfortime 300 -TERM), would wait for previous instance to be stopped as TERM is default, ldap should not specify -TERM signal in fact. also respect --waitname in ssd kill mode --- lib/functions | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/functions b/lib/functions index f74eb3e4..5bb35657 100644 --- a/lib/functions +++ b/lib/functions @@ -848,16 +848,25 @@ killproc() { # works only with pidfile if is_no "$RC_LOGGING" && [ "$pidfile" ]; then local sig=${killlevel:--TERM} retry - # retry only if signal is not specified, + # do not retry if signal is specified, # as otherwise impossible to send HUP if process pid stays in pidfile. - if [ "${killlevel+set}" = "set" ]; then + # however, do retry if --waitfortime was specified + if [ "${killlevel+set}" = "set" ] && [ -z "$waittime" ]; then # if we send HUP it's ok if process does not die retry="--oknodo" else - retry="--retry ${sig#-}/10/${sig#-}/60/KILL/10" + local waitretry + : ${waittime=10} + : ${waitretry=$(($waittime * 2))} + + # 1. kill with $sig, wait $delay + # 2. kill with $sig, wait $waittime + # 3. kill with KILL, wait $waitretry + retry="--retry ${sig#-}/${delay}/${sig#-}/${waittime}/KILL/${waitretry}" fi /sbin/start-stop-daemon -q --stop \ $retry \ + ${waitname:+--name $waitname} \ -s ${sig#-} \ ${pidfile:+--pidfile $pidfile} result=$? -- 2.44.0