]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: with --pid, ensure all inotify events are processed
authorPádraig Brady <P@draigBrady.com>
Wed, 7 Jun 2017 07:17:57 +0000 (00:17 -0700)
committerPádraig Brady <P@draigBrady.com>
Wed, 7 Jun 2017 17:09:46 +0000 (10:09 -0700)
* NEWS: Mention the bug fix.
* src/tail.c (tail_forever_inotify): With --pid, avoid waiting
for new events if there are still events to process.
* tests/tail-2/inotify-dir-recreate.sh: Adjust to trigger.

NEWS
src/tail.c
tests/tail-2/inotify-dir-recreate.sh

diff --git a/NEWS b/NEWS
index c811dbcb50371ced2bbc1c410d67d90d00fd076f..508c08f6bcba3cabd6eaa482176cea939b914f71 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   tail -F 'dir/file' is now monitored even when 'dir' is replaced.
   [bug introduced with inotify support added in coreutils-7.5]
 
+  tail -f with --pid=PID will now process all inotify events.
+  Previously events may have been ignored completely upon PID death,
+  or ignored until future events on the monitored files.
+  [bug introduced with inotify support added in coreutils-7.5]
+
   uptime no longer outputs the AM/PM component of the current time,
   as that's inconsistent with the 24 hour time format used.
   [bug introduced in coreutils-7.0]
index 6328fe0ef8fc41fc05706ad079f84877002de7a0..3582321bce882b3e731871bcf87cd5bb09e5c07a 100644 (file)
@@ -1577,7 +1577,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
 
       /* When watching a PID, ensure that a read from WD will not block
          indefinitely.  */
-      if (pid)
+      if (pid && (len <= evbuf_off))
         {
           if (writer_is_dead)
             exit (EXIT_SUCCESS);
index 02ddf96a4b447274d098b937b4e8ec14f5a5d8cf..5c74c1dfa7f8f285a75e7df98172bed828986994 100755 (executable)
@@ -54,7 +54,7 @@ grep_timeout_ ()
 mkdir dir && echo 'inotify' > dir/file || framework_failure_
 
 #tail must print content of the file to stdout, verify
-timeout 60 tail -F dir/file >out 2>&1 & pid=$!
+timeout 60 tail --pid=$$ -F dir/file >out 2>&1 & pid=$!
 grep_timeout_ 'inotify' 'out' ||
 { cleanup_fail_ 'file to be tailed does not exist'; }