mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
tests: aux.sh better loop logic
Instead of using pipe for read and haveing no chance to modify shell vars inside such loop use <( ) and keep using bash arrays.
This commit is contained in:
parent
b97f75b133
commit
2baac408fc
@ -504,20 +504,18 @@ kill_tagged_processes() {
|
|||||||
local wait
|
local wait
|
||||||
|
|
||||||
# read uses all vars within pipe subshell
|
# read uses all vars within pipe subshell
|
||||||
rm -f PIDS
|
local pids=()
|
||||||
print_procs_by_tag_ "$@" | while read -r pid wait; do
|
while read -r pid wait; do
|
||||||
if test -n "$pid" ; then
|
if test -n "$pid" ; then
|
||||||
echo "## killing tagged process: $pid ${wait:0:120}..."
|
echo "## killing tagged process: $pid ${wait:0:120}..."
|
||||||
kill -TERM "$pid" 2>/dev/null || true
|
kill -TERM "$pid" 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
echo "$pid" >> PIDS
|
pids+=( "$pid" )
|
||||||
done
|
done < <(print_procs_by_tag_ "$@")
|
||||||
|
|
||||||
test -s PIDS || return 0
|
|
||||||
|
|
||||||
# wait if process exited and eventually -KILL
|
# wait if process exited and eventually -KILL
|
||||||
wait=0
|
wait=0
|
||||||
for pid in $(< PIDS) ; do
|
for pid in "${pids[@]}" ; do
|
||||||
while ps "$pid" > /dev/null && test "$wait" -le 10; do
|
while ps "$pid" > /dev/null && test "$wait" -le 10; do
|
||||||
sleep .2
|
sleep .2
|
||||||
wait=$(( wait + 1 ))
|
wait=$(( wait + 1 ))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user