summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormostang.com!davidm <mostang.com!davidm>2002-04-25 06:47:29 +0000
committermostang.com!davidm <mostang.com!davidm>2002-04-25 06:47:29 +0000
commit72e98c4610ffd161fff52c327482a455bd0e5d8b (patch)
tree136d4b97bd5b49711b0935a5a3b4ebb9ad350843 /tests
parent4d37950b2c182e7bc1de517aa27c9d87a28d5183 (diff)
downloadlibunwind-72e98c4610ffd161fff52c327482a455bd0e5d8b.tar.gz
(sighandler): New function.
(main): Install SIGTERM handler and send SIGTERM to self to test backtracing through signal handler. (Logical change 1.18)
Diffstat (limited to 'tests')
-rw-r--r--tests/bt.c15
1 files changed, 15 insertions, 0 deletions
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 <execinfo.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <libunwind.h>
@@ -67,8 +68,22 @@ foo (void)
}
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;
}