summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-06-29 21:00:17 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2017-06-29 22:23:17 +0200
commit491fcd2a921bea6d63bbb243bfd972fda3bb6c67 (patch)
treebee996d142eae67532df589f32a9a432f2bcb843
parent96fcf82dddd7bcc7b5c09de09d49d70a04ae8b12 (diff)
downloadlvm2-491fcd2a921bea6d63bbb243bfd972fda3bb6c67.tar.gz
tests: aux.sh fix pid handling
Modification of pids is local (to subshell caused by pipeline). pids was modified in a subshell. That change might be lost.
-rw-r--r--test/lib/aux.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index f39d40029..4e2b2461e 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -500,17 +500,20 @@ kill_tagged_processes() {
local wait
# read uses all vars within pipe subshell
+ rm -f PIDS
print_procs_by_tag_ "$@" | while read -r pid wait; do
if test -n "$pid" ; then
echo "Killing tagged process: $pid ${wait:0:120}..."
kill -TERM "$pid" 2>/dev/null || true
fi
- pids="$pids $pid"
+ echo "$pid" >> PIDS
done
+ test -f PIDS || return 0
+
# wait if process exited and eventually -KILL
wait=0
- for pid in $pids ; do
+ for pid in $(< PIDS) ; do
while ps "$pid" > /dev/null && test "$wait" -le 10; do
sleep .2
wait=$(( wait + 1 ))