mirror of
https://github.com/deajan/obackup.git
synced 2024-12-25 15:03:41 +01:00
Update ofunctions
This commit is contained in:
parent
fbd5317010
commit
be4ba9f366
@ -2,8 +2,8 @@
|
|||||||
#### OFUNCTIONS FULL SUBSET ####
|
#### OFUNCTIONS FULL SUBSET ####
|
||||||
#### OFUNCTIONS MINI SUBSET ####
|
#### OFUNCTIONS MINI SUBSET ####
|
||||||
|
|
||||||
_OFUNCTIONS_VERSION=2.1.4-dev
|
_OFUNCTIONS_VERSION=2.1.4-rc1
|
||||||
_OFUNCTIONS_BUILD=2017052201
|
_OFUNCTIONS_BUILD=2017052902
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
||||||
@ -71,6 +71,8 @@ fi
|
|||||||
#### DEBUG SUBSET END ####
|
#### DEBUG SUBSET END ####
|
||||||
|
|
||||||
SCRIPT_PID=$$
|
SCRIPT_PID=$$
|
||||||
|
|
||||||
|
# TODO: Check if %N works on MacOS
|
||||||
TSTAMP=$(date '+%Y%m%dT%H%M%S.%N')
|
TSTAMP=$(date '+%Y%m%dT%H%M%S.%N')
|
||||||
|
|
||||||
LOCAL_USER=$(whoami)
|
LOCAL_USER=$(whoami)
|
||||||
@ -317,15 +319,29 @@ 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 ?
|
||||||
|
|
||||||
# Warning: pgrep does not exist in cygwin, have this checked in CheckEnvironment
|
# Paranoid checks, we can safely assume that $pid shouldn't be 0 nor 1
|
||||||
if children="$(pgrep -P "$pid")"; then
|
if [ $(IsNumeric "$pid") -eq 0 ] || [ "$pid" == "" ] || [ "$pid" == "0" ] || [ "$pid" == "1" ]; then
|
||||||
for child in $children; do
|
Logger "Bogus pid given [$pid]." "CRITICAL"
|
||||||
Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG
|
return 1
|
||||||
KillChilds "$child" true
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
|
||||||
|
if kill -0 "$pid" > /dev/null 2>&1; then
|
||||||
|
# Warning: pgrep is not native on cygwin, have this checked in CheckEnvironment
|
||||||
|
if children="$(pgrep -P "$pid")"; then
|
||||||
|
if [[ "$pid" == *"$children"* ]]; then
|
||||||
|
Logger "Bogus pgrep implementation." "CRITICAL"
|
||||||
|
children="${children/$pid/}"
|
||||||
|
fi
|
||||||
|
for child in $children; do
|
||||||
|
Logger "Launching KillChilds \"$child\" true" "DEBUG" #__WITH_PARANOIA_DEBUG
|
||||||
|
KillChilds "$child" true
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try to kill nicely, if not, wait 15 seconds to let Trap actions happen before killing
|
||||||
if [ "$self" == true ]; then
|
if [ "$self" == true ]; then
|
||||||
|
# We need to check for pid again because it may have disappeared after recursive function call
|
||||||
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"
|
||||||
Logger "Sent SIGTERM to process [$pid]." "DEBUG"
|
Logger "Sent SIGTERM to process [$pid]." "DEBUG"
|
||||||
|
Loading…
Reference in New Issue
Block a user