Created attachment 79325 [details]
From the documentation, one might understand that sd_journal_seek_tail move to the last entry and that a subsequent sd_journal_next would access that entry.
(Because it is worded very much like the docs for sd_journal_seek_head, which works that way.)
In fact, sd_journal_seek_tail seems to move to just _after_ the last entry, and one needs to use sd_journal_previous to access it. I think this should be documented more clearly.
What's worse is that if does call sd_journal_next after sd_journal_seek_tail, this is successful and will access random entries. Instead, I would expect sd_journal_next to return 0 (or an error). The attached program demonstrates this.
I might try to provide some patches (docs and code), but with low priority.
Not that even with improved documentation, it would still be very good to have sd_journal_next after sd_journal_seek_tail return an error instead of succeeding and moving to a random entry.
(In reply to comment #1)
> Not that even with improved documentation, it would still be very good to
> have sd_journal_next after sd_journal_seek_tail return an error instead of
> succeeding and moving to a random entry.
You're right, I somehow missed the part about random results...
It would be great if you turned you test program directly into a test that we can include in systemd. I did something like that with your other program (http://cgit.freedesktop.org/systemd/systemd/commit/?id=7a050b54).
I'm pretty sure that sd_journal_next after sd_journal_seek_tail should return 0.
I ran into this bug. Mailing list thread: http://lists.freedesktop.org/archives/systemd-devel/2014-October/023916.html