]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/journal-iterate-poll.c
verify: use manager_load_startable_unit_or_warn() to load units for verification
[thirdparty/systemd.git] / man / journal-iterate-poll.c
CommitLineData
929f5263 1#include <poll.h>
1027e0dc 2#include <time.h>
929f5263
ZJS
3#include <systemd/sd-journal.h>
4
5int wait_for_changes(sd_journal *j) {
1027e0dc 6 uint64_t t;
929f5263 7 int msec;
1027e0dc 8 struct pollfd pollfd;
929f5263 9
1027e0dc 10 sd_journal_get_timeout(j, &t);
929f5263
ZJS
11 if (t == (uint64_t) -1)
12 msec = -1;
13 else {
14 struct timespec ts;
15 uint64_t n;
16 clock_gettime(CLOCK_MONOTONIC, &ts);
17 n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
18 msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
19 }
20
21 pollfd.fd = sd_journal_get_fd(j);
22 pollfd.events = sd_journal_get_events(j);
23 poll(&pollfd, 1, msec);
24 return sd_journal_process(j);
25}