From 2c51055209ee708dbbab1e3d70c4826bcb537710 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 12 Apr 2016 09:41:16 +0200 Subject: [PATCH] More debugging love for KillChilds --- dev/debug_obackup.sh | 26 ++++++++++++-------------- dev/n_obackup.sh | 13 ++++++------- dev/ofunctions.sh | 13 ++++++------- obackup.sh | 25 +++++++++++-------------- 4 files changed, 35 insertions(+), 42 deletions(-) diff --git a/dev/debug_obackup.sh b/dev/debug_obackup.sh index 9009de7..f34e70a 100755 --- a/dev/debug_obackup.sh +++ b/dev/debug_obackup.sh @@ -5,10 +5,10 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre -PROGRAM_BUILD=2016040603 +PROGRAM_BUILD=2016041201 IS_STABLE=no -## FUNC_BUILD=2016041201 +## FUNC_BUILD=2016041202 ## 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 @@ -157,13 +157,13 @@ function KillChilds { if children="$(pgrep -P "$pid")"; then for child in $children; do - Logger "Launching KillChilds \"$child\" true" "DEBUG" + Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG KillChilds "$child" true done fi # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing - if [ "$self" == true ]; then + if ( [ "$self" == true ] && eval $PROCESS_TEST_CMD > /dev/null 2>&1); then Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then @@ -173,12 +173,11 @@ function KillChilds { if [ $? != 0 ]; then Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" return 1 - else - return 0 fi - else - return 0 fi + return 0 + else + return 0 fi } @@ -2391,6 +2390,11 @@ if [ "$IS_STABLE" != "yes" ]; then Logger "This is an unstable dev build. Please use with caution." "WARN" fi +DATE=$(date) +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" GetLocalOS InitLocalOSSettings @@ -2401,12 +2405,6 @@ Init PostInit CheckCurrentConfig -DATE=$(date) -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" - if [ "$REMOTE_OPERATION" == "yes" ]; then GetRemoteOS InitRemoteOSSettings diff --git a/dev/n_obackup.sh b/dev/n_obackup.sh index b9c8f3a..b2edb89 100755 --- a/dev/n_obackup.sh +++ b/dev/n_obackup.sh @@ -5,7 +5,7 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre -PROGRAM_BUILD=2016040603 +PROGRAM_BUILD=2016041201 IS_STABLE=no source "./ofunctions.sh" @@ -1359,6 +1359,11 @@ if [ "$IS_STABLE" != "yes" ]; then Logger "This is an unstable dev build. Please use with caution." "WARN" fi +DATE=$(date) +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" GetLocalOS InitLocalOSSettings @@ -1369,12 +1374,6 @@ Init PostInit CheckCurrentConfig -DATE=$(date) -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" - if [ "$REMOTE_OPERATION" == "yes" ]; then GetRemoteOS InitRemoteOSSettings diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index c6e0b20..dcbee15 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,4 +1,4 @@ -## FUNC_BUILD=2016041201 +## FUNC_BUILD=2016041202 ## 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 @@ -147,13 +147,13 @@ function KillChilds { if children="$(pgrep -P "$pid")"; then for child in $children; do - Logger "Launching KillChilds \"$child\" true" "DEBUG" + Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG KillChilds "$child" true done fi # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing - if [ "$self" == true ]; then + if ( [ "$self" == true ] && eval $PROCESS_TEST_CMD > /dev/null 2>&1); then Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then @@ -163,12 +163,11 @@ function KillChilds { if [ $? != 0 ]; then Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" return 1 - else - return 0 fi - else - return 0 fi + return 0 + else + return 0 fi } diff --git a/obackup.sh b/obackup.sh index 0f76ea4..775b369 100755 --- a/obackup.sh +++ b/obackup.sh @@ -5,10 +5,10 @@ PROGRAM="obackup" AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/obackup - ozy@netpower.fr" PROGRAM_VERSION=2.0-pre -PROGRAM_BUILD=2016040603 +PROGRAM_BUILD=2016041201 IS_STABLE=no -## FUNC_BUILD=2016041201 +## FUNC_BUILD=2016041202 ## 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 @@ -147,13 +147,12 @@ function KillChilds { if children="$(pgrep -P "$pid")"; then for child in $children; do - Logger "Launching KillChilds \"$child\" true" "DEBUG" KillChilds "$child" true done fi # Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing - if [ "$self" == true ]; then + if ( [ "$self" == true ] && eval $PROCESS_TEST_CMD > /dev/null 2>&1); then Logger "Sending SIGTERM to process [$pid]." "DEBUG" kill -s SIGTERM "$pid" if [ $? != 0 ]; then @@ -163,12 +162,11 @@ function KillChilds { if [ $? != 0 ]; then Logger "Sending SIGKILL to process [$pid] failed." "DEBUG" return 1 - else - return 0 fi - else - return 0 fi + return 0 + else + return 0 fi } @@ -2281,6 +2279,11 @@ if [ "$IS_STABLE" != "yes" ]; then Logger "This is an unstable dev build. Please use with caution." "WARN" fi +DATE=$(date) +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" +Logger "--------------------------------------------------------------------" "NOTICE" +Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" GetLocalOS InitLocalOSSettings @@ -2291,12 +2294,6 @@ Init PostInit CheckCurrentConfig -DATE=$(date) -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "$DRY_WARNING $DATE - $PROGRAM v$PROGRAM_VERSION $BACKUP_TYPE script begin." "NOTICE" -Logger "--------------------------------------------------------------------" "NOTICE" -Logger "Backup instance [$INSTANCE_ID] launched as $LOCAL_USER@$LOCAL_HOST (PID $SCRIPT_PID)" "NOTICE" - if [ "$REMOTE_OPERATION" == "yes" ]; then GetRemoteOS InitRemoteOSSettings