]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: reinstate inotify use with FIFOs
authorPádraig Brady <P@draigBrady.com>
Tue, 22 Aug 2017 04:00:01 +0000 (21:00 -0700)
committerPádraig Brady <P@draigBrady.com>
Fri, 25 Aug 2017 02:20:47 +0000 (19:20 -0700)
commit v8.27-44-g18f6b22 was too aggressive in
only allowing inotify use with regular files. This will
support responsive processing of `tail -f fifo | ...`

* src/tail.c (any_non_regular): Adjust to allow FIFOs
since inotify supports these well.
* tests/tail-2/inotify-only-regular.sh: Adjust comment.

src/tail.c
tests/tail-2/inotify-only-regular.sh

index ce34886cde636ef9ec71594aae2a0dfee90d98b9..316e72ec5eaa1db61cfba9070699b3b41944ad2f 100644 (file)
@@ -1332,15 +1332,15 @@ any_symlinks (const struct File_spec *f, size_t n_files)
 }
 
 /* Return true if any of the N_FILES files in F is not
-   a regular file.  This is used to avoid adding inotify
+   a regular file or fifo.  This is used to avoid adding inotify
    watches on a device file for example, which inotify
    will accept, but not give any events for.  */
 
 static bool
-any_non_regular (const struct File_spec *f, size_t n_files)
+any_non_regular_fifo (const struct File_spec *f, size_t n_files)
 {
   for (size_t i = 0; i < n_files; i++)
-    if (0 <= f[i].fd && ! S_ISREG (f[i].mode))
+    if (0 <= f[i].fd && ! S_ISREG (f[i].mode) && ! S_ISFIFO (f[i].mode))
       return true;
   return false;
 }
@@ -2460,7 +2460,7 @@ main (int argc, char **argv)
                                || any_remote_file (F, n_files)
                                || ! any_non_remote_file (F, n_files)
                                || any_symlinks (F, n_files)
-                               || any_non_regular (F, n_files)
+                               || any_non_regular_fifo (F, n_files)
                                || (!ok && follow_mode == Follow_descriptor)))
         disable_inotify = true;
 
index 4d106fbb8a5a0c6ffa60636dea2cf283f8e1a423..9f8da94a5ccf732c4f51732fec3b7a15e2c8e734 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# ensure that tail -f only uses inotify for regular files
+# ensure that tail -f only uses inotify for regular files or fifos
 
 # Copyright (C) 2017 Free Software Foundation, Inc.