1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2004-2005, 2007-2012 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 static volatile int done
[2];
27 static volatile int repeats
[2];
28 static int itimer
[2] = { ITIMER_REAL
, ITIMER_VIRTUAL
};
29 static int alarm
[2] = { SIGALRM
, SIGVTALRM
};
37 case SIGALRM
: sigi
= 0; break;
38 case SIGVTALRM
: sigi
= 1; break;
41 if (repeats
[sigi
]++ > 3)
43 /* Hit with enough signals, cancel everything and get out. */
45 struct itimerval itime
;
46 memset (&itime
, 0, sizeof (itime
));
47 setitimer (itimer
[sigi
], &itime
, NULL
);
50 struct sigaction action
;
51 memset (&action
, 0, sizeof (action
));
52 action
.sa_handler
= SIG_IGN
;
53 sigaction (sig
, &action
, NULL
);
58 /* Set up a nested virtual timer. */
61 /* Wait until a signal has become pending, that way when this
62 handler returns it will be immediatly delivered leading to
63 back-to-back signals. */
66 if (sigpending (&set
) < 0)
71 if (sigismember (&set
, sig
))
80 /* Set up the signal handler. */
81 for (i
= 0; i
< 2; i
++)
83 struct sigaction action
;
84 memset (&action
, 0, sizeof (action
));
85 action
.sa_handler
= handler
;
86 sigaction (alarm
[i
], &action
, NULL
);
89 /* Set up a rapidly repeating timers. A timer, rather than SIGSEGV,
90 is used as after a timer handler returns the interrupted code can
91 safely resume. The intent is for the program to swamp GDB with a
92 backlog of pending signals. */
93 for (i
= 0; i
< 2; i
++)
95 struct itimerval itime
;
96 memset (&itime
, 0, sizeof (itime
));
97 itime
.it_interval
.tv_usec
= 1;
98 itime
.it_value
.tv_usec
= 250 * 1000;
99 setitimer (itimer
[i
], &itime
, NULL
);
103 while (!done
[0] && !done
[1]); /* infinite loop */
This page took 0.031831 seconds and 4 git commands to generate.