]> git.ipfire.org Git - thirdparty/coreutils.git/commit
tail: avoid a race where we could miss new data with --pid
authorPádraig Brady <P@draigBrady.com>
Thu, 1 Oct 2009 07:36:25 +0000 (08:36 +0100)
committerPádraig Brady <P@draigBrady.com>
Fri, 2 Oct 2009 13:00:06 +0000 (14:00 +0100)
commitf8726e05c4ec1141fb3ffad1c9ec3838f59182cb
tree7153d27a45fb3d26b186473daf8443fc4654f377
parent95c01c656e061bccbab41fa651c99cb7041c9937
tail: avoid a race where we could miss new data with --pid

* src/tail.c (tail_forever, tail_forever_inotify): Close a race in
tail_forever_inotify where new data written after the file check by
a now dead process, but before the pid check, is not output.  We use
the POSIX guarantee that read() and write() are serialized wrt each
other even in separate processes, to assume full file consistency
after exit() and so poll for new data _after_ the writer has exited.
This also allows us to not redundantly _wait_ for new data if the
process is dead.
* tests/tail-2/pid: Remove the now partially invalid sub second sleep
check as we now don't unconditionally wait, and replace it with a check
for the redundant sleep.  Also clarify some of the existing comments.
* NEWS: Mention the fix.
NEWS
src/tail.c
tests/tail-2/pid