diff options
Diffstat (limited to 'man/man2/mmap.2')
| -rw-r--r-- | man/man2/mmap.2 | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/man/man2/mmap.2 b/man/man2/mmap.2 index 28ad07198a..23ffcd758c 100644 --- a/man/man2/mmap.2 +++ b/man/man2/mmap.2 @@ -948,6 +948,7 @@ to output the desired bytes. .SS Program source .\" SRC BEGIN (mmap.c) .EX +#include <err.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> @@ -956,9 +957,6 @@ to output the desired bytes. #include <sys/types.h> #include <unistd.h> \& -#define handle_error(msg) \[rs] - do { perror(msg); exit(EXIT_FAILURE); } while (0) -\& int main(int argc, char *argv[]) { @@ -976,10 +974,10 @@ main(int argc, char *argv[]) \& fd = open(argv[1], O_RDONLY); if (fd == \-1) - handle_error("open"); + err(EXIT_FAILURE, "open"); \& if (fstat(fd, &sb) == \-1) /* To obtain file size */ - handle_error("fstat"); + err(EXIT_FAILURE, "fstat"); \& offset = atoi(argv[2]); pa_offset = offset & \[ti](sysconf(_SC_PAGE_SIZE) \- 1); @@ -1003,12 +1001,12 @@ main(int argc, char *argv[]) addr = mmap(NULL, length + offset \- pa_offset, PROT_READ, MAP_PRIVATE, fd, pa_offset); if (addr == MAP_FAILED) - handle_error("mmap"); + err(EXIT_FAILURE, "mmap"); \& s = write(STDOUT_FILENO, addr + offset \- pa_offset, length); if (s != length) { if (s == \-1) - handle_error("write"); + err(EXIT_FAILURE, "write"); \& fprintf(stderr, "partial write"); exit(EXIT_FAILURE); |
