diff options
-rw-r--r-- | regress/sys/kern/signal/siginfo_addr/Makefile | 5 | ||||
-rw-r--r-- | regress/sys/kern/signal/siginfo_addr/siginfo_addr.c | 41 |
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; +} |