]> sourceware.org Git - lvm2.git/commitdiff
tests: aux.sh fix pid handling
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 29 Jun 2017 19:00:17 +0000 (21:00 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 29 Jun 2017 20:23:17 +0000 (22:23 +0200)
Modification of pids is local (to subshell caused by pipeline).
pids was modified in a subshell. That change might be lost.

test/lib/aux.sh

index f39d4002942edf84a725fbda60bd75d8883a8824..4e2b2461ec06f195cadde2416b229baeec8b4cd4 100644 (file)
@@ -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 ))
This page took 0.038485 seconds and 5 git commands to generate.