]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/journal-iterate-poll.c
journald: bring order of MaxLevelXYZ= setting explanations in sync with listed names
[thirdparty/systemd.git] / man / journal-iterate-poll.c
CommitLineData
1fe6d37e 1/* SPDX-License-Identifier: MIT-0 */
f4d74c61 2
040cb664 3#define _GNU_SOURCE 1
929f5263 4#include <poll.h>
1027e0dc 5#include <time.h>
929f5263
ZJS
6#include <systemd/sd-journal.h>
7
8int wait_for_changes(sd_journal *j) {
1027e0dc 9 uint64_t t;
929f5263 10 int msec;
1027e0dc 11 struct pollfd pollfd;
929f5263 12
1027e0dc 13 sd_journal_get_timeout(j, &t);
929f5263
ZJS
14 if (t == (uint64_t) -1)
15 msec = -1;
16 else {
17 struct timespec ts;
18 uint64_t n;
19 clock_gettime(CLOCK_MONOTONIC, &ts);
20 n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
21 msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
22 }
23
24 pollfd.fd = sd_journal_get_fd(j);
25 pollfd.events = sd_journal_get_events(j);
26 poll(&pollfd, 1, msec);
27 return sd_journal_process(j);
28}