tail: consistently output all data for truncated files
commitb28ff6a3c6ad25d877b63013af245de5d6c70b10
authorPádraig Brady <P@draigBrady.com>
Mon, 11 May 2015 13:25:19 +0000 (11 14:25 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 11 May 2015 22:16:14 +0000 (11 23:16 +0100)
treee1e0d4e15c02f8041b930e5fb9902334c295a9b2
parentcf06a872e74b45588c2e64903f7fc99cf2aafe27
tail: consistently output all data for truncated files

Generally if logs are truncated, they're truncated to 0 length,
so output all existing data when our heuristic determines truncation.
Note with inotify, truncate() and write() are often determined
independently and so all data would be written if that was the case.

* src/tail.c (check_fspec): Reset file offset to 0 upon truncation.
(tail_forever): Likewise.
(recheck): Add a FIXME for the related issue where tail may lose
data due to tail discounting older log files too early.
* tests/tail-2/truncate.sh: A new test.
* tests/local.mk: Reference the new test.
* NEWS: Mention the fix.
NEWS
src/tail.c
tests/local.mk
tests/tail-2/truncate.sh [new file with mode: 0755]