binutils-gdb/gdb/testsuite/gdb.server/multi-ui-errors.c
Tom de Vries ed32754a8c [gdb/testsuite] Fix gdb.server/multi-ui-errors.exp for remote target
Test-case gdb.server/multi-ui-errors.exp fails for target board
remote-gdbserver-on-localhost with REMOTE_TARGET_USERNAME=remote-target:
...
(gdb) PASS: gdb.server/multi-ui-errors.exp: interact with GDB's main UI
Executing on target: kill -9 6447    (timeout = 300)
builtin_spawn [open ...]^M
XYZ1ZYX
sh: line 0: kill: (6447) - Operation not permitted
...

The problem is that the kill command:
...
remote_exec target "kill -9 $gdbserver_pid"
...
intended to kill gdbserver instead tries to kill the ssh client session in
which the gdbserver runs, and fails because it's trying as the remote target
user (remote-target on localhost) to kill a pid owned by the the build user
($USER on localhost).

Fix this by getting the gdbserver pid using the ppid trick from
server-kill.exp.

Likewise in gdb.server/server-kill-python.exp.

Tested on x86_64-linux.
2023-03-09 10:45:03 +01:00

38 lines
999 B
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2019-2023 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
pid_t server_pid;
int
main (void)
{
int i;
server_pid = getppid ();
printf ("@@XX@@ Inferior Starting @@XX@@\n");
for (i = 0; i < 120; ++i)
sleep (1);
return 0;
}