Files
binutils-gdb/gdb/testsuite/gdb.base/sigrepeat.c
Tom de Vries 8f6606b6e3 [gdb] Fix common misspellings
Fix the following common misspellings:
...
accidently -> accidentally
additonal -> additional
addresing -> addressing
adress -> address
agaisnt -> against
albiet -> albeit
arbitary -> arbitrary
artifical -> artificial
auxillary -> auxiliary
auxilliary -> auxiliary
bcak -> back
begining -> beginning
cannonical -> canonical
compatiblity -> compatibility
completetion -> completion
diferent -> different
emited -> emitted
emiting -> emitting
emmitted -> emitted
everytime -> every time
excercise -> exercise
existance -> existence
fucntion -> function
funtion -> function
guarentee -> guarantee
htis -> this
immediatly -> immediately
layed -> laid
noone -> no one
occurances -> occurrences
occured -> occurred
originaly -> originally
preceeded -> preceded
preceeds -> precedes
propogate -> propagate
publically -> publicly
refering -> referring
substract -> subtract
substracting -> subtracting
substraction -> subtraction
taht -> that
targetting -> targeting
teh -> the
thier -> their
thru -> through
transfered -> transferred
transfering -> transferring
upto -> up to
vincinity -> vicinity
whcih -> which
whereever -> wherever
wierd -> weird
withing -> within
writen -> written
wtih -> with
doesnt -> doesn't
...

Tested on x86_64-linux.
2024-10-06 07:59:48 +02:00

106 lines
2.7 KiB
C

/* This testcase is part of GDB, the GNU debugger.
Copyright 2004-2024 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 <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
static volatile int done[2];
static volatile int repeats[2];
static int itimer[2] = { ITIMER_REAL, ITIMER_VIRTUAL };
static int alarm[2] = { SIGALRM, SIGVTALRM };
static void
handler (int sig)
{
int sigi;
switch (sig)
{
case SIGALRM: sigi = 0; break;
case SIGVTALRM: sigi = 1; break;
default: abort ();
}
if (repeats[sigi]++ > 3)
{
/* Hit with enough signals, cancel everything and get out. */
{
struct itimerval itime;
memset (&itime, 0, sizeof (itime));
setitimer (itimer[sigi], &itime, NULL);
}
{
struct sigaction action;
memset (&action, 0, sizeof (action));
action.sa_handler = SIG_IGN;
sigaction (sig, &action, NULL);
}
done[sigi] = 1;
return;
}
/* Set up a nested virtual timer. */
while (1)
{
/* Wait until a signal has become pending, that way when this
handler returns it will be immediately delivered leading to
back-to-back signals. */
sigset_t set;
sigemptyset (&set);
if (sigpending (&set) < 0)
{
perror ("sigrepeat");
abort ();
}
if (sigismember (&set, sig))
break;
}
} /* handler */
int
main ()
{
int i;
/* Set up the signal handler. */
for (i = 0; i < 2; i++)
{
struct sigaction action;
memset (&action, 0, sizeof (action));
action.sa_handler = handler;
sigaction (alarm[i], &action, NULL);
}
/* Set up a rapidly repeating timers. A timer, rather than SIGSEGV,
is used as after a timer handler returns the interrupted code can
safely resume. The intent is for the program to swamp GDB with a
backlog of pending signals. */
for (i = 0; i < 2; i++)
{
struct itimerval itime;
memset (&itime, 0, sizeof (itime));
itime.it_interval.tv_usec = 1;
itime.it_value.tv_usec = 250 * 1000;
setitimer (itimer[i], &itime, NULL);
}
/* Wait. */
while (!done[0] && !done[1]); /* infinite loop */
return 0;
}