mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-28 11:55:23 +03:00
24 lines
548 B
C
24 lines
548 B
C
|
#include <poll.h>
|
||
|
#include <systemd/sd-journal.h>
|
||
|
|
||
|
int wait_for_changes(sd_journal *j) {
|
||
|
struct pollfd pollfd;
|
||
|
int msec;
|
||
|
|
||
|
sd_journal_get_timeout(m, &t);
|
||
|
if (t == (uint64_t) -1)
|
||
|
msec = -1;
|
||
|
else {
|
||
|
struct timespec ts;
|
||
|
uint64_t n;
|
||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||
|
n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
|
||
|
msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
|
||
|
}
|
||
|
|
||
|
pollfd.fd = sd_journal_get_fd(j);
|
||
|
pollfd.events = sd_journal_get_events(j);
|
||
|
poll(&pollfd, 1, msec);
|
||
|
return sd_journal_process(j);
|
||
|
}
|