+2020-05-15  Pedro Alves  <palves@redhat.com>
+
+       * gdb.multi/multi-kill.exp: Wrap in namespace.
+       (start_inferior): Add TESTPID parameter.  Use it instead of the
+       testpid global.
+       (top level): Define empty TESTPID array, and pass it down to
+       start_inferior.
+
 2020-05-14  Tom de Vries  <tdevries@suse.de>
 
        * gdb.fortran/nested-funcs-2.exp: Use gdb_test_stdio to test inferior
 
     clean_restart ${binfile}
 }
 
+# Wrap the entire test in a namespace to avoid contaminating other tests.
+namespace eval $testfile {
+
 # Start inferior NUM and record its PID in the TESTPID array.
 
-proc start_inferior {num} {
+proc start_inferior {num testpid} {
     with_test_prefix "start_inferior $num" {
-       global testpid binfile srcfile
+       upvar $testpid tpid
+       global binfile srcfile
 
        if {$num != 1} {
            gdb_test "add-inferior" "Added inferior .*" \
        gdb_run_cmd
        gdb_test "" ".*reakpoint .*, initialized .*${srcfile}.*" "run"
 
-       set testpid($num) [get_integer_valueof "pid" -1]
-       if {$testpid($num) == -1} {
+       set tpid($num) [get_integer_valueof "pid" -1]
+       if {$tpid($num) == -1} {
            return -1
        }
 
 # is killed while we're handling a killed event.
 set NUM_INFS 10
 
+# The array holding each inferior's PID, indexed by inferior number.
+array set testpid {}
+
 for {set i 1} {$i <= $NUM_INFS} {incr i} {
-    if {[start_inferior $i] < 0} {
+    if {[start_inferior $i testpid] < 0} {
        return -1
     }
 }
            "continue to SIGKILL"
     }
 }
+
+}