&& ([target_info gdb_protocol] == "remote"
            || [target_info gdb_protocol] == "extended-remote")} {
 
-       gdb_test_multiple "maint show target-non-stop" "" {
-           -wrap -re "(is|currently) on.*" {
-           }
-           -wrap -re "(is|currently) off.*" {
-               unsupported "can't issue commands while target is running"
-               return 0
-           }
+       if {![is_target_non_stop]} {
+           unsupported "can't issue commands while target is running"
+           return 0
        }
     }
 
 
         && ([target_info gdb_protocol] == "remote"
             || [target_info gdb_protocol] == "extended-remote")} {
 
-       set test "maint show target-non-stop"
-       gdb_test_multiple "maint show target-non-stop" $test {
-           -re "(is|currently) on.*$gdb_prompt $" {
-           }
-           -re "(is|currently) off.*$gdb_prompt $" {
-               unsupported "can't issue info threads while target is running"
-               return 0
-           }
+       if {![is_target_non_stop]} {
+           unsupported "can't issue info threads while target is running"
+           return 0
        }
     }
 
 
        && ([target_info gdb_protocol] == "remote"
            || [target_info gdb_protocol] == "extended-remote")} {
 
-       gdb_test_multiple "maint show target-non-stop" "" {
-           -wrap -re "(is|currently) on.*" {
-           }
-           -wrap -re "(is|currently) off.*" {
-               unsupported "can't issue commands while target is running"
-               return 0
-           }
+       if {![is_target_non_stop]} {
+           unsupported "can't issue commands while target is running"
+           return 0
        }
     }
 
 
     && ([target_info gdb_protocol] == "remote"
        || [target_info gdb_protocol] == "extended-remote")} {
 
-    set test "maint show target-non-stop"
-    gdb_test_multiple "maint show target-non-stop" $test {
-       -re "(is|currently) on.*$gdb_prompt $" {
-       }
-       -re "(is|currently) off.*$gdb_prompt $" {
-           unsupported "bg attach: can't issue info threads while target is running"
-           return 0
-       }
+    if {![is_target_non_stop]} {
+       unsupported "bg attach: can't issue info threads while target is running"
+       return 0
     }
 }
 
 
        start_gdb_for_test $condition_eval $target_non_stop \
            $non_stop $displaced
 
-       gdb_test_multiple "maint show target-non-stop" "" {
-           -wrap -re "(is|currently) on.*" {
-           }
-           -wrap -re "(is|currently) off.*" {
-               return
-           }
+       if {![is_target_non_stop]} {
+           return
        }
     }
 
 
     }
 }
 
+# Return false if the current target is not operating in non-stop
+# mode, otherwise, return true.
+#
+# The inferior will need to have started running in order to get the
+# correct result.
+
+proc is_target_non_stop { {testname ""} } {
+    # For historical reasons we assume non-stop mode is on.  If the
+    # maintenance command fails for any reason then we're going to
+    # return true.
+    set is_non_stop true
+    gdb_test_multiple "maint show target-non-stop" $testname {
+       -wrap -re "(is|currently) on.*" {
+           set is_non_stop true
+       }
+       -wrap -re "(is|currently) off.*" {
+           set is_non_stop false
+       }
+    }
+    return $is_non_stop
+}
+
 # Check if the compiler emits epilogue information associated
 # with the closing brace or with the last statement line.
 #