From 1913c897f1d118c129b16c3ece7c005b791f2ed5 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 12 Apr 2016 09:14:44 +0200 Subject: [PATCH] More debugging in KillChilds --- dev/debug_obackup.sh | 16 +++++++++++----- dev/ofunctions.sh | 16 +++++++++++----- obackup.sh | 16 +++++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/dev/debug_obackup.sh b/dev/debug_obackup.sh index b892444..9009de7 100755 --- a/dev/debug_obackup.sh +++ b/dev/debug_obackup.sh @@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016040603 IS_STABLE=no -## FUNC_BUILD=2016041001 +## FUNC_BUILD=2016041201 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -164,16 +164,22 @@ function KillChilds { # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing if [ "$self" == true ]; then - Logger "Killing process $pid" "DEBUG" + Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then - sleep 15 && kill -9 "$pid" & - return 1 + sleep 15 + Logger "Sending SIGTERM to process [$pid] failed." "DEBUG" + kill -9 "$pid" + if [ $? != 0 ]; then + Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" + return 1 + else + return 0 + fi else return 0 fi fi - # sleep 15 needs to wait before killing itself } function SendAlert { diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 8d375a4..c6e0b20 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,4 +1,4 @@ -## FUNC_BUILD=2016041001 +## FUNC_BUILD=2016041201 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -154,16 +154,22 @@ function KillChilds { # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing if [ "$self" == true ]; then - Logger "Killing process $pid" "DEBUG" + Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then - sleep 15 && kill -9 "$pid" & - return 1 + sleep 15 + Logger "Sending SIGTERM to process [$pid] failed." "DEBUG" + kill -9 "$pid" + if [ $? != 0 ]; then + Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" + return 1 + else + return 0 + fi else return 0 fi fi - # sleep 15 needs to wait before killing itself } function SendAlert { diff --git a/obackup.sh b/obackup.sh index 8b9688c..0f76ea4 100755 --- a/obackup.sh +++ b/obackup.sh @@ -8,7 +8,7 @@ PROGRAM_VERSION=2.0-pre PROGRAM_BUILD=2016040603 IS_STABLE=no -## FUNC_BUILD=2016041001 +## FUNC_BUILD=2016041201 ## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode @@ -154,16 +154,22 @@ function KillChilds { # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing if [ "$self" == true ]; then - Logger "Killing process $pid" "DEBUG" + Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then - sleep 15 && kill -9 "$pid" & - return 1 + sleep 15 + Logger "Sending SIGTERM to process [$pid] failed." "DEBUG" + kill -9 "$pid" + if [ $? != 0 ]; then + Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" + return 1 + else + return 0 + fi else return 0 fi fi - # sleep 15 needs to wait before killing itself } function SendAlert {