1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2025-01-22 16:20:29 +01:00

(sighandler): New function.

(main): Install SIGTERM handler and send SIGTERM to self to test backtracing through
	signal handler.

(Logical change 1.18)
This commit is contained in:
mostang.com!davidm 2002-04-25 06:47:29 +00:00
parent 4d37950b2c
commit 72e98c4610

View file

@ -15,6 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. */
#include <execinfo.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <libunwind.h>
@ -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;
}