From 5ee49fea85cad878db0e99cc06e25121574e3316 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Mon, 21 Aug 2017 21:00:01 -0700 Subject: [PATCH] tail: reinstate inotify use with FIFOs 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 | 8 ++++---- tests/tail-2/inotify-only-regular.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tail.c b/src/tail.c index ce34886cde..316e72ec5e 100644 --- a/src/tail.c +++ b/src/tail.c @@ -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; diff --git a/tests/tail-2/inotify-only-regular.sh b/tests/tail-2/inotify-only-regular.sh index 4d106fbb8a..9f8da94a5c 100755 --- a/tests/tail-2/inotify-only-regular.sh +++ b/tests/tail-2/inotify-only-regular.sh @@ -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. -- 2.47.2