diff options
Diffstat (limited to 'man/man2/poll.2')
| -rw-r--r-- | man/man2/poll.2 | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/man/man2/poll.2 b/man/man2/poll.2 index 85856bb34d..e3e5119d2e 100644 --- a/man/man2/poll.2 +++ b/man/man2/poll.2 @@ -555,6 +555,7 @@ at which point the file descriptor was closed and the program terminated. \& Licensed under GNU General Public License v2 or later. */ +#include <err.h> #include <fcntl.h> #include <poll.h> #include <stdio.h> @@ -562,9 +563,6 @@ at which point the file descriptor was closed and the program terminated. #include <sys/types.h> #include <unistd.h> \& -#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \[rs] - } while (0) -\& int main(int argc, char *argv[]) { @@ -582,14 +580,14 @@ main(int argc, char *argv[]) num_open_fds = nfds = argc \- 1; pfds = calloc(nfds, sizeof(struct pollfd)); if (pfds == NULL) - errExit("malloc"); + err(EXIT_FAILURE, "malloc"); \& /* Open each file on command line, and add it to \[aq]pfds\[aq] array. */ \& for (nfds_t j = 0; j < nfds; j++) { pfds[j].fd = open(argv[j + 1], O_RDONLY); if (pfds[j].fd == \-1) - errExit("open"); + err(EXIT_FAILURE, "open"); \& printf("Opened \[rs]"%s\[rs]" on fd %d\[rs]n", argv[j + 1], pfds[j].fd); \& @@ -603,7 +601,7 @@ main(int argc, char *argv[]) printf("About to poll()\[rs]n"); ready = poll(pfds, nfds, \-1); if (ready == \-1) - errExit("poll"); + err(EXIT_FAILURE, "poll"); \& printf("Ready: %d\[rs]n", ready); \& @@ -619,13 +617,13 @@ main(int argc, char *argv[]) if (pfds[j].revents & POLLIN) { s = read(pfds[j].fd, buf, sizeof(buf)); if (s == \-1) - errExit("read"); + err(EXIT_FAILURE, "read"); printf(" read %zd bytes: %.*s\[rs]n", s, (int) s, buf); } else { /* POLLERR | POLLHUP */ printf(" closing fd %d\[rs]n", pfds[j].fd); if (close(pfds[j].fd) == \-1) - errExit("close"); + err(EXIT_FAILURE, "close"); num_open_fds\-\-; } } |
