]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail: avoid an inotify portability problem in kernels prior to 2.6.21
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 2 Jul 2009 21:38:46 +0000 (23:38 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 3 Jul 2009 15:52:30 +0000 (17:52 +0200)
* src/tail.c (tail_forever_inotify): Handle the special case in which
an old inotify watcher returns 0.  Affects kernels in [2.6.13, 2.6.21).

src/tail.c

index 89c43b8273ca72f141b95dda61d35f0d061f71ce..b3ebba9d608e2b7f75730bb1f2633ba6c346e641 100644 (file)
@@ -1259,8 +1259,9 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files)
           evbuf_off = 0;
 
           /* For kernels prior to 2.6.21, read returns 0 when the buffer
-             is too small.  FIXME: handle that.  */
-          if (len == SAFE_READ_ERROR && errno == EINVAL && max_realloc--)
+             is too small.  */
+          if ((len == 0 || (len == SAFE_READ_ERROR && errno == EINVAL))
+              && max_realloc--)
             {
               len = 0;
               evlen *= 2;
@@ -1268,7 +1269,7 @@ tail_forever_inotify (int wd, struct File_spec *f, int n_files)
               continue;
             }
 
-          if (len == SAFE_READ_ERROR)
+          if (len == 0 || len == SAFE_READ_ERROR)
             error (EXIT_FAILURE, errno, _("error reading inotify event"));
         }