From 72e98c4610ffd161fff52c327482a455bd0e5d8b Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Thu, 25 Apr 2002 06:47:29 +0000 Subject: [PATCH] (sighandler): New function. (main): Install SIGTERM handler and send SIGTERM to self to test backtracing through signal handler. (Logical change 1.18) --- tests/bt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/bt.c b/tests/bt.c index daed52f5..d73eeeed 100644 --- a/tests/bt.c +++ b/tests/bt.c @@ -15,6 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include +#include #include #include #include @@ -66,9 +67,23 @@ foo (void) printf ("[%d] ip=%p\n", i, buffer[i]); } +int +sighandler (int signal, void *siginfo, struct sigcontext *sc) +{ + void *buffer[20]; + int n; + + printf ("sighandler: got signal %d @ %lx\n", signal, sc->sc_ip); + + do_backtrace(); +} + int main (int argc, char **argv) { foo (); + + signal (SIGTERM, sighandler); + kill (getpid (), SIGTERM); return 0; }