diff options
Diffstat (limited to 'man/man2/mprotect.2')
| -rw-r--r-- | man/man2/mprotect.2 | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/man/man2/mprotect.2 b/man/man2/mprotect.2 index 773d93dc9c..269ae204d6 100644 --- a/man/man2/mprotect.2 +++ b/man/man2/mprotect.2 @@ -293,6 +293,7 @@ Got SIGSEGV at address: 0x804e000 \& .\" SRC BEGIN (mprotect.c) .EX +#include <err.h> #include <malloc.h> #include <signal.h> #include <stdio.h> @@ -300,9 +301,6 @@ Got SIGSEGV at address: 0x804e000 #include <sys/mman.h> #include <unistd.h> \& -#define handle_error(msg) \[rs] - do { perror(msg); exit(EXIT_FAILURE); } while (0) -\& static char *buffer; \& static void @@ -328,24 +326,24 @@ main(void) sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; if (sigaction(SIGSEGV, &sa, NULL) == \-1) - handle_error("sigaction"); + err(EXIT_FAILURE, "sigaction"); \& pagesize = sysconf(_SC_PAGE_SIZE); if (pagesize == \-1) - handle_error("sysconf"); + err(EXIT_FAILURE, "sysconf"); \& /* Allocate a buffer aligned on a page boundary; initial protection is PROT_READ | PROT_WRITE. */ \& buffer = memalign(pagesize, 4 * pagesize); if (buffer == NULL) - handle_error("memalign"); + err(EXIT_FAILURE, "memalign"); \& printf("Start of region: %p\[rs]n", buffer); \& if (mprotect(buffer + pagesize * 2, pagesize, PROT_READ) == \-1) - handle_error("mprotect"); + err(EXIT_FAILURE, "mprotect"); \& for (char *p = buffer ; ; ) *(p++) = \[aq]a\[aq]; |
