From f8726e05c4ec1141fb3ffad1c9ec3838f59182cb Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Thu, 1 Oct 2009 08:36:25 +0100 Subject: 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 | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index e7e4ddccf..aff0744a1 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,12 @@ GNU coreutils NEWS -*- outline -*- from a failed stat/lstat. For example ls -Lis now prints "?", not "0", for the inode number and allocated size of a dereferenced dangling symlink. + tail --follow --pid now avoids a race condition where data written + just before the process dies might not have been output by tail. + Also, tail no longer delays at all when the specified pid is not live. + [The race was introduced in coreutils-7.5, + and the unnecessary delay was present since textutils-1.22o] + ** Portability On Solaris 9, many commands would mistakenly treat file/ the same as -- cgit v1.2.3-54-g00ecf