tail: avoid an inotify portability problem in kernels prior to 2.6.21

* 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).
This commit is contained in:
Giuseppe Scrivano authored and Jim Meyering committed 2009-07-03 17:52:30 +02:00
1 parent 66ac50e723
commit d9f83f9a60
1 file changed
+4 -3
+4 -3
View 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"));
}