Rebuilt targets

This commit is contained in:
deajan 2017-05-28 20:17:57 +02:00
parent 011a316f94
commit 300108641a
2 changed files with 24 additions and 4 deletions

View File

@ -41,7 +41,7 @@ IS_STABLE=yes
_OFUNCTIONS_VERSION=2.1.4-dev _OFUNCTIONS_VERSION=2.1.4-dev
_OFUNCTIONS_BUILD=2017052201 _OFUNCTIONS_BUILD=2017052802
_OFUNCTIONS_BOOTSTRAP=true _OFUNCTIONS_BOOTSTRAP=true
## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
@ -347,14 +347,24 @@ function KillChilds {
local pid="${1}" # Parent pid to kill childs local pid="${1}" # Parent pid to kill childs
local self="${2:-false}" # Should parent be killed too ? local self="${2:-false}" # Should parent be killed too ?
if [ $(IsNumeric "$pid") -eq 0 ] || [ "$pid" == "" ]; then
Logger "Bogus pid given [$pid]." "CRITICAL"
return 1
fi
# Warning: pgrep does not exist in cygwin, have this checked in CheckEnvironment # Warning: pgrep does not exist in cygwin, have this checked in CheckEnvironment
if children="$(pgrep -P "$pid")"; then if children="$(pgrep -P "$pid")"; then
if [[ "$pid" == *"$children"* ]]; then
Logger "Bogus pgrep implementation." "CRITICAL"
children="${children/$pid/}"
fi
for child in $children; do for child in $children; do
Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_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 ]; then
if kill -0 "$pid" > /dev/null 2>&1; then if kill -0 "$pid" > /dev/null 2>&1; then
kill -s TERM "$pid" kill -s TERM "$pid"

View File

@ -10,7 +10,7 @@ IS_STABLE=yes
_OFUNCTIONS_VERSION=2.1.4-dev _OFUNCTIONS_VERSION=2.1.4-dev
_OFUNCTIONS_BUILD=2017052201 _OFUNCTIONS_BUILD=2017052802
_OFUNCTIONS_BOOTSTRAP=true _OFUNCTIONS_BOOTSTRAP=true
## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2017 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
@ -301,13 +301,23 @@ function KillChilds {
local pid="${1}" # Parent pid to kill childs local pid="${1}" # Parent pid to kill childs
local self="${2:-false}" # Should parent be killed too ? local self="${2:-false}" # Should parent be killed too ?
if [ $(IsNumeric "$pid") -eq 0 ] || [ "$pid" == "" ]; then
Logger "Bogus pid given [$pid]." "CRITICAL"
return 1
fi
# Warning: pgrep does not exist in cygwin, have this checked in CheckEnvironment # Warning: pgrep does not exist in cygwin, have this checked in CheckEnvironment
if children="$(pgrep -P "$pid")"; then if children="$(pgrep -P "$pid")"; then
if [[ "$pid" == *"$children"* ]]; then
Logger "Bogus pgrep implementation." "CRITICAL"
children="${children/$pid/}"
fi
for child in $children; do for child in $children; do
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 ]; then
if kill -0 "$pid" > /dev/null 2>&1; then if kill -0 "$pid" > /dev/null 2>&1; then
kill -s TERM "$pid" kill -s TERM "$pid"