diff options
author | Christian Hesse <mail@eworm.de> | 2014-10-14 15:04:31 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2014-10-14 15:04:31 +0200 |
commit | d6720eec30e42f263b0d311b107b752979517717 (patch) | |
tree | 18d9f1b897a56d672b62cf6a8eb538594ea44813 | |
parent | e64b0040cd203659265e884989daf23dd1fcc641 (diff) | |
download | journal-notify-d6720eec30e42f263b0d311b107b752979517717.tar.gz journal-notify-d6720eec30e42f263b0d311b107b752979517717.tar.zst |
call sd_journal_{seek_tail,previous}() before adding matches
I had some trouble with the code jumping to older entries. Possibly this
was caused by adding matches too early.
-rw-r--r-- | journal-notify.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/journal-notify.c b/journal-notify.c index 0dbb83a..f733477 100644 --- a/journal-notify.c +++ b/journal-notify.c @@ -100,6 +100,18 @@ int main(int argc, char **argv) { goto out10; } + /* seek to the end of the journal */ + if ((rc = sd_journal_seek_tail(journal)) < 0) { + fprintf(stderr, "Failed to seek to the tail: %s\n", strerror(-rc)); + goto out30; + } + + /* we are behind the last entry, so use previous one */ + if ((rc = sd_journal_previous(journal)) < 0) { + fprintf(stderr, "Failed to iterate to previous entry: %s\n", strerror(-rc)); + goto out30; + } + /* get command line options - part II*/ while ((i = getopt_long(argc, argv, optstring, options_long, NULL)) != -1) { switch (i) { @@ -156,18 +168,6 @@ int main(int argc, char **argv) { } } - /* seek to the end of the journal */ - if ((rc = sd_journal_seek_tail(journal)) < 0) { - fprintf(stderr, "Failed to seek to the tail: %s\n", strerror(-rc)); - goto out30; - } - - /* we are behind the last entry, so use previous one */ - if ((rc = sd_journal_previous(journal)) < 0) { - fprintf(stderr, "Failed to iterate to previous entry: %s\n", strerror(-rc)); - goto out30; - } - if (notify_init(program) == FALSE) { fprintf(stderr, "Failed to initialize notify.\n"); rc = EXIT_FAILURE; |