From a098ca41eb72ab5b1105e54e6fbaa71069b0ef1b Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 19 May 2015 11:44:42 +0200 Subject: make sure not to show old entries --- journal-notify.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/journal-notify.c b/journal-notify.c index 98649ba..1a737bd 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -68,6 +68,7 @@ int main(int argc, char **argv) { int regex_flags = REG_NOSUB; sd_journal * journal; + uint8_t old_entry = 1; const void * data; size_t length; @@ -195,6 +196,7 @@ int main(int argc, char **argv) { fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-rc)); goto out40; } else if (rc == 0) { + old_entry = 0; if (verbose > 2) printf("Waiting...\n"); if ((rc = sd_journal_wait(journal, (uint64_t) -1)) < 0) { @@ -204,6 +206,14 @@ int main(int argc, char **argv) { continue; } + /* Looks like there is a but in libsystemd journal handling + * that jumps to wrong entries. Just skip old entries until we + * have a recent ones. */ + if (old_entry > 0) { + fprintf(stderr, "This is an old entry, ignoring.\n"); + continue; + } + /* get MESSAGE field */ if ((rc = sd_journal_get_data(journal, "MESSAGE", &data, &length)) < 0) { fprintf(stderr, "Failed to read message field: %s\n", strerror(-rc)); -- cgit v1.2.3-54-g00ecf