From: Rainer Orth Date: Tue, 8 Aug 2023 08:13:58 +0000 (+0200) Subject: Guard against killing unrelated processes in amd64-disp-step.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67be0489f28161239442dae38d4a14a38cb824de;p=binutils-gdb.git Guard against killing unrelated processes in amd64-disp-step.exp When testing current gdb trunk on Solaris/amd64, the whole session was reliably terminated by make check. I could trace this to the following entry in gdb.arch/amd64-disp-step/gdb.log: FAIL: gdb.arch/amd64-disp-step.exp: add into rcx: send_signal=on: get inferior pid Executing on target: kill -ALRM -1 (timeout = 300) builtin_spawn -ignore SIGHUP kill -ALRM -1 If $inferior_pid doesn't refer to a single process for some reason, this kill would terminate either a process group or the whole session. This patch avoids this by ensuring that the pid arg is positive. Tested on amd64-pc-solaris2.11 and x86_64-pc-linux-gnu. Co-Authored-By: Andrew Burgess Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp index 0919e71d715..79e752ce878 100644 --- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp +++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp @@ -222,7 +222,12 @@ proc rip_test { reg test_start_label test_end_label signal_modes } { # If we use 'signal' to send the signal GDB doesn't actually do # the displaced step, but instead just delivers the signal. set inferior_pid [get_inferior_pid] - remote_exec target "kill -ALRM $inferior_pid" + # Ensure that $inferior_pid refers to a single process. + gdb_assert {[expr $inferior_pid > 0]} \ + "check for a sane inferior pid" + if {$inferior_pid > 0} { + remote_exec target "kill -ALRM $inferior_pid" + } } gdb_test "continue" \