summaryrefslogtreecommitdiff
path: root/src/tail.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-04-24 23:20:01 +0200
committerJim Meyering <meyering@redhat.com>2011-04-25 10:59:15 +0200
commit61de57cd2369914542d44d32b4a2e001f638ada8 (patch)
treef50084d419f5f759bbd04ed90e74424813c432dc /src/tail.c
parent32eb31999f62605872cfc1c32b85bd9a5fcd198e (diff)
downloadcoreutils-61de57cd2369914542d44d32b4a2e001f638ada8.tar.xz
tail --follow=name no longer implies --retry
* src/tail.c (tail_forever_inotify): Just as without inotify, tail --follow=name now terminates when the last tailed-by-name file is unlinked or moved aside. This bug was introduced on 2009-06-15 via commit ae494d4b, "tail: use inotify if it is available". Reported by Tim Underwood in http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22286 * NEWS (Bug fixes): Mention this. * tests/tail-2/follow-name: Test for this. * tests/Makefile.am (TESTS): Add it.
Diffstat (limited to 'src/tail.c')
-rw-r--r--src/tail.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tail.c b/src/tail.c
index 88fbd10b8..e6d816432 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1432,6 +1432,16 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files,
struct File_spec *fspec;
struct inotify_event *ev;
+ /* When following by name without --retry, and the last file has
+ been unlinked or renamed-away, diagnose it and return. */
+ if (follow_mode == Follow_name
+ && ! reopen_inaccessible_files
+ && hash_get_n_entries (wd_to_name) == 0)
+ {
+ error (0, 0, _("no files remaining"));
+ return false;
+ }
+
/* When watching a PID, ensure that a read from WD will not block
indefinitely. */
if (pid)