about summary refs log tree commit diff stats
path: root/tests32/test18.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests32/test18.c')
-rw-r--r--tests32/test18.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests32/test18.c b/tests32/test18.c
new file mode 100644
index 00000000..f609b754
--- /dev/null
+++ b/tests32/test18.c
@@ -0,0 +1,30 @@
+#include <signal.h>
+#include <setjmp.h>
+#include <stdio.h>
+
+static jmp_buf context_buf;
+
+static void segv_handler(int sig)
+{
+	printf("sig = %d\n", sig);
+	longjmp(context_buf, 1);
+}
+
+void test()
+{
+	if(!setjmp(context_buf)) {
+		int *bad_ptr = (int*)0xdeadbeef;
+		printf("*bad_ptr = %d\n", *bad_ptr);
+	} else {
+		printf("got bad_ptr\n");
+	}
+}
+
+int main()
+{
+	if(signal(SIGSEGV, segv_handler) == SIG_ERR)
+		printf("Err = %m\n");
+	//printf("handler = %p\n", segv_handler);
+	test();
+	return 0;
+}