coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tail: with --pid, ensure all inotify events are processed


From: Pádraig Brady
Subject: [PATCH] tail: with --pid, ensure all inotify events are processed
Date: Wed, 7 Jun 2017 00:23:51 -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                                 | 3 +++
 src/tail.c                           | 2 +-
 tests/tail-2/inotify-dir-recreate.sh | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index c811dbc..3330370 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,9 @@ 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 no longer ignores some inotify events.
+  [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]
diff --git a/src/tail.c b/src/tail.c
index 6328fe0..3582321 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -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);
diff --git a/tests/tail-2/inotify-dir-recreate.sh 
b/tests/tail-2/inotify-dir-recreate.sh
index 02ddf96..5c74c1d 100755
--- a/tests/tail-2/inotify-dir-recreate.sh
+++ b/tests/tail-2/inotify-dir-recreate.sh
@@ -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'; }
 
-- 
2.9.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]