summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-03-03 04:11:45 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-03-04 05:06:48 +0900
commitd9e2af0ae8b0fb4eff4a06447cde99002712dd3e (patch)
tree27565b953767b44f1ba4ec535ebed6c96738ef1e /src/journal/journalctl.c
parentc4febde9d0f2faf13aff3a5285c8fdff22073dc6 (diff)
downloadsystemd-d9e2af0ae8b0fb4eff4a06447cde99002712dd3e.tar.gz
tree-wide: use ppoll_usec()
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r--src/journal/journalctl.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 823cf0a25f..6b06320d78 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -5,7 +5,6 @@
#include <fnmatch.h>
#include <getopt.h>
#include <linux/fs.h>
-#include <poll.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
@@ -2095,8 +2094,6 @@ static int wait_for_change(sd_journal *j, int poll_fd) {
{ .fd = poll_fd, .events = POLLIN },
{ .fd = STDOUT_FILENO },
};
-
- struct timespec ts;
usec_t timeout;
int r;
@@ -2110,21 +2107,16 @@ static int wait_for_change(sd_journal *j, int poll_fd) {
if (r < 0)
return log_error_errno(r, "Failed to determine journal waiting time: %m");
- if (ppoll(pollfds, ELEMENTSOF(pollfds),
- timeout == USEC_INFINITY ? NULL : timespec_store(&ts, timeout), NULL) < 0) {
- if (errno == EINTR)
- return 0;
-
- return log_error_errno(errno, "Couldn't wait for journal event: %m");
- }
+ r = ppoll_usec(pollfds, ELEMENTSOF(pollfds), timeout);
+ if (r == -EINTR)
+ return 0;
+ if (r < 0)
+ return log_error_errno(r, "Couldn't wait for journal event: %m");
- if (pollfds[1].revents & (POLLHUP|POLLERR|POLLNVAL)) /* STDOUT has been closed? */
+ if (pollfds[1].revents & (POLLHUP|POLLERR)) /* STDOUT has been closed? */
return log_debug_errno(SYNTHETIC_ERRNO(ECANCELED),
"Standard output has been closed.");
- if (pollfds[0].revents & POLLNVAL)
- return log_debug_errno(SYNTHETIC_ERRNO(EBADF), "Change fd closed?");
-
r = sd_journal_process(j);
if (r < 0)
return log_error_errno(r, "Failed to process journal events: %m");