]>
Commit | Line | Data |
---|---|---|
929f5263 ZJS |
1 | #include <poll.h> |
2 | #include <systemd/sd-journal.h> | |
3 | ||
4 | int wait_for_changes(sd_journal *j) { | |
5 | struct pollfd pollfd; | |
6 | int msec; | |
7 | ||
8 | sd_journal_get_timeout(m, &t); | |
9 | if (t == (uint64_t) -1) | |
10 | msec = -1; | |
11 | else { | |
12 | struct timespec ts; | |
13 | uint64_t n; | |
14 | clock_gettime(CLOCK_MONOTONIC, &ts); | |
15 | n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000; | |
16 | msec = t > n ? (int) ((t - n + 999) / 1000) : 0; | |
17 | } | |
18 | ||
19 | pollfd.fd = sd_journal_get_fd(j); | |
20 | pollfd.events = sd_journal_get_events(j); | |
21 | poll(&pollfd, 1, msec); | |
22 | return sd_journal_process(j); | |
23 | } |