summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-23 19:15:42 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-02-23 19:15:42 +0000
commit2b3187bd451c1c265e1fd63a9f958096d62a9b23 (patch)
tree2392f16ca5ce4f08503f16bf98e26a6ece8dad1c /regress/sys
parent0bcf017689e6646a728a88dbba06660474420a1e (diff)
simple test to see if siginfo passes si_addr
Diffstat (limited to 'regress/sys')
-rw-r--r--regress/sys/kern/signal/siginfo_addr/Makefile5
-rw-r--r--regress/sys/kern/signal/siginfo_addr/siginfo_addr.c41
2 files changed, 46 insertions, 0 deletions
diff --git a/regress/sys/kern/signal/siginfo_addr/Makefile b/regress/sys/kern/signal/siginfo_addr/Makefile
new file mode 100644
index 00000000000..e66bfde4b94
--- /dev/null
+++ b/regress/sys/kern/signal/siginfo_addr/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2002/02/23 19:15:41 deraadt Exp $
+
+PROG= siginfo_addr
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/kern/signal/siginfo_addr/siginfo_addr.c b/regress/sys/kern/signal/siginfo_addr/siginfo_addr.c
new file mode 100644
index 00000000000..668771b7bbd
--- /dev/null
+++ b/regress/sys/kern/signal/siginfo_addr/siginfo_addr.c
@@ -0,0 +1,41 @@
+#include <sys/types.h>
+#include <sys/signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#define FAULTADDR 0x123123
+
+void
+handler(int sig, siginfo_t *sip, void *scp)
+{
+ char buf[1024];
+
+ if (sip == NULL)
+ _exit(1);
+ if (sip->si_addr == 0) /* wrong address */
+ _exit(1);
+
+ // snprintf(buf, sizeof buf, "addr %p\n", sip->si_addr);
+ // write(STDOUT_FILENO, buf, strlen(buf));
+ _exit(0);
+}
+
+
+int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof sa);
+ sigfillset(&sa);
+ sa.sa_sigaction = handler;
+ sa.sa_flags = SA_SIGINFO;
+
+ sigaction(SIGSEGV, &sa, NULL);
+ sigaction(SIGBUS, &sa, NULL);
+
+ *(char *)FAULTADDR = 0;
+}