1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2004, 2005, 2007 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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 static volatile int done
[2];
28 static volatile int repeats
[2];
29 static int itimer
[2] = { ITIMER_REAL
, ITIMER_VIRTUAL
};
30 static int alarm
[2] = { SIGALRM
, SIGVTALRM
};
38 case SIGALRM
: sigi
= 0; break;
39 case SIGVTALRM
: sigi
= 1; break;
42 if (repeats
[sigi
]++ > 3)
44 /* Hit with enough signals, cancel everything and get out. */
46 struct itimerval itime
;
47 memset (&itime
, 0, sizeof (itime
));
48 setitimer (itimer
[sigi
], &itime
, NULL
);
51 struct sigaction action
;
52 memset (&action
, 0, sizeof (action
));
53 action
.sa_handler
= SIG_IGN
;
54 sigaction (sig
, &action
, NULL
);
59 /* Set up a nested virtual timer. */
62 /* Wait until a signal has become pending, that way when this
63 handler returns it will be immediatly delivered leading to
64 back-to-back signals. */
67 if (sigpending (&set
) < 0)
72 if (sigismember (&set
, sig
))
81 /* Set up the signal handler. */
82 for (i
= 0; i
< 2; i
++)
84 struct sigaction action
;
85 memset (&action
, 0, sizeof (action
));
86 action
.sa_handler
= handler
;
87 sigaction (alarm
[i
], &action
, NULL
);
90 /* Set up a rapidly repeating timers. A timer, rather than SIGSEGV,
91 is used as after a timer handler returns the interrupted code can
92 safely resume. The intent is for the program to swamp GDB with a
93 backlog of pending signals. */
94 for (i
= 0; i
< 2; i
++)
96 struct itimerval itime
;
97 memset (&itime
, 0, sizeof (itime
));
98 itime
.it_interval
.tv_usec
= 1;
99 itime
.it_value
.tv_usec
= 250 * 1000;
100 setitimer (itimer
[i
], &itime
, NULL
);
104 while (!done
[0] && !done
[1]); /* infinite loop */
This page took 0.031088 seconds and 4 git commands to generate.