More debugging love for KillChilds

This commit is contained in:
deajan 2016-04-12 10:16:21 +02:00
parent e832cb700b
commit e1b1643b1a
3 changed files with 41 additions and 27 deletions

View File

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040701 PROGRAM_BUILD=2016040701
IS_STABLE=yes IS_STABLE=yes
## FUNC_BUILD=2016041001 ## FUNC_BUILD=2016041202
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## 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 ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -156,23 +156,28 @@ function KillChilds {
if children="$(pgrep -P "$pid")"; then if children="$(pgrep -P "$pid")"; then
for child in $children; do for child in $children; do
Logger "Launching KillChilds \"$child\" true" "DEBUG" Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG
KillChilds "$child" true KillChilds "$child" true
done done
fi fi
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing # 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 "Killing process $pid" "DEBUG" Logger "Sending SIGTERM to process [$pid]." "DEBUG"
kill -s SIGTERM "$pid" kill -s SIGTERM "$pid"
if [ $? != 0 ]; then if [ $? != 0 ]; then
sleep 15 && kill -9 "$pid" & 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 return 1
fi
fi
return 0
else else
return 0 return 0
fi fi
fi
# sleep 15 needs to wait before killing itself
} }
function SendAlert { function SendAlert {

View File

@ -1,4 +1,4 @@
## FUNC_BUILD=2016041001 ## FUNC_BUILD=2016041202
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## 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 ## 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,23 +147,28 @@ function KillChilds {
if children="$(pgrep -P "$pid")"; then if children="$(pgrep -P "$pid")"; then
for child in $children; do for child in $children; do
Logger "Launching KillChilds \"$child\" true" "DEBUG" Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG
KillChilds "$child" true KillChilds "$child" true
done done
fi fi
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing # 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 "Killing process $pid" "DEBUG" Logger "Sending SIGTERM to process [$pid]." "DEBUG"
kill -s SIGTERM "$pid" kill -s SIGTERM "$pid"
if [ $? != 0 ]; then if [ $? != 0 ]; then
sleep 15 && kill -9 "$pid" & 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 return 1
fi
fi
return 0
else else
return 0 return 0
fi fi
fi
# sleep 15 needs to wait before killing itself
} }
function SendAlert { function SendAlert {

View File

@ -7,7 +7,7 @@ PROGRAM_VERSION=1.1-pre
PROGRAM_BUILD=2016040701 PROGRAM_BUILD=2016040701
IS_STABLE=yes IS_STABLE=yes
## FUNC_BUILD=2016041001 ## FUNC_BUILD=2016041202
## BEGIN Generic functions for osync & obackup written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## 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 ## type -p does not work on platforms other than linux (bash). If if does not work, always assume output is not a zero exitcode
@ -146,23 +146,27 @@ function KillChilds {
if children="$(pgrep -P "$pid")"; then if children="$(pgrep -P "$pid")"; then
for child in $children; do for child in $children; do
Logger "Launching KillChilds \"$child\" true" "DEBUG"
KillChilds "$child" true KillChilds "$child" true
done done
fi fi
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing # 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 "Killing process $pid" "DEBUG" Logger "Sending SIGTERM to process [$pid]." "DEBUG"
kill -s SIGTERM "$pid" kill -s SIGTERM "$pid"
if [ $? != 0 ]; then if [ $? != 0 ]; then
sleep 15 && kill -9 "$pid" & 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 return 1
fi
fi
return 0
else else
return 0 return 0
fi fi
fi
# sleep 15 needs to wait before killing itself
} }
function SendAlert { function SendAlert {