Made WaitFor and ParallelExec functions more robust
This commit is contained in:
parent
9804334821
commit
a31cceedc6
|
@ -1,6 +1,6 @@
|
|||
#### MINIMAL-FUNCTION-SET BEGIN ####
|
||||
|
||||
## FUNC_BUILD=2016082902
|
||||
## FUNC_BUILD=2016083001
|
||||
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
|
||||
|
||||
## To use in a program, define the following variables:
|
||||
|
@ -676,6 +676,7 @@ function WaitForTaskCompletion {
|
|||
fi
|
||||
|
||||
for pid in "${pidsArray[@]}"; do
|
||||
if [ "$pid" != "" ]; then
|
||||
if kill -0 $pid > /dev/null 2>&1; then
|
||||
# Handle uninterruptible sleep state or zombies by ommiting them from running process array (How to kill that is already dead ? :)
|
||||
#TODO(high): have this tested on *BSD, Mac & Win
|
||||
|
@ -697,6 +698,7 @@ function WaitForTaskCompletion {
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
pidsArray=("${newPidsArray[@]}")
|
||||
|
@ -749,6 +751,7 @@ function ParallelExec {
|
|||
|
||||
newPidsArray=()
|
||||
for pid in "${pidsArray[@]}"; do
|
||||
if [ "$pid" != "" ]; then
|
||||
# Handle uninterruptible sleep state or zombies by ommiting them from running process array (How to kill that is already dead ? :)
|
||||
if kill -0 $pid > /dev/null 2>&1; then
|
||||
pidState=$(ps -p$pid -o state= 2 > /dev/null)
|
||||
|
@ -764,6 +767,7 @@ function ParallelExec {
|
|||
retvalAll=$((retvalAll+1))
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
pidsArray=("${newPidsArray[@]}")
|
||||
|
||||
|
|
Loading…
Reference in New Issue