Files
binutils-gdb/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
Rainer Orth 92137da015 Can't interrupt process without controlling terminal on Solaris (PR gdb/8527)
If gdb attaches to a process that either has no controlling terminal,
or the controlling terminal differs from the one gdb is running under,
break/^C doesn't interrupt the debugged process on Solaris.

Fixed as follows, analogous to what all all other targets do.  Patch from
the PR, recently re-submitted by Brian Vandenberg.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2019-02-28  Brian Vandenberg  <phantall@gmail.com>
	    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gdb:
	PR gdb/8527
	* procfs.c (proc_wait_for_stop): Wrap write of PCWSTOP in
	set_sigint_trap, clear_sigint_trap.

	gdb/testsuite:
	PR gdb/8527
	* gdb.base/interrupt-daemon-attach.c,
	gdb.base/interrupt-daemon-attach.exp: New test.
2019-02-28 16:09:05 +01:00

62 lines
1.2 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2017-2019 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 <stdlib.h>
#include <unistd.h>
/* GDB reads this to figure out the child's PID. */
pid_t child_pid;
void
marker (void)
{
}
int
main ()
{
/* Don't let the test case run forever. */
alarm (60);
child_pid = fork ();
switch (child_pid)
{
case -1:
return 1;
case 0:
break;
default:
while (1)
{
marker ();
usleep (1000);
}
}
/* Detach from controlling terminal. */
if (setsid () == (pid_t) -1)
return 1;
for (;;)
;
return 0;
}