diff options
author | Christian Hesse <mail@eworm.de> | 2015-05-19 11:44:42 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2015-05-19 11:44:42 +0200 |
commit | a098ca41eb72ab5b1105e54e6fbaa71069b0ef1b (patch) | |
tree | 22ea9a2c06224205cc84b8f85e724bf44217520a | |
parent | 90068a6e5f0f33579cd5e59d22217366ff2c162b (diff) | |
download | journal-notify-a098ca41eb72ab5b1105e54e6fbaa71069b0ef1b.tar.gz journal-notify-a098ca41eb72ab5b1105e54e6fbaa71069b0ef1b.tar.zst |
make sure not to show old entries
-rw-r--r-- | journal-notify.c | 10 |
1 files changed, 10 insertions, 0 deletions
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)); |