1#include <stdio.h>
2#include <stdlib.h>
3#include <signal.h>
4#include "tests/sys_mman.h"
5
6static void handler(int sig, siginfo_t *info, void *v)
7{
8	printf("info: sig=%d code=%d addr=%p\n",
9	       info->si_signo, info->si_code, info->si_addr);
10	exit(0);
11}
12
13/* Blocking a fault (for example SIGSEGV) won't work,
14   and is the same as having the default handler. */
15int main()
16{
17	int* unmapped_page = get_unmapped_page();
18	struct sigaction sa;
19	sigset_t mask;
20
21	sa.sa_sigaction = handler;
22	sigemptyset(&sa.sa_mask);
23	sa.sa_flags = SA_SIGINFO;
24
25	sigaction(SIGSEGV, &sa, NULL);
26
27	sigfillset(&mask);
28	sigprocmask(SIG_BLOCK, &mask, NULL);
29
30	*(volatile int *)unmapped_page = 213;
31
32	return 0;
33}
34