From d9f83f9a603a2f5ecdc13bbe65e22aba49d43d66 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 2 Jul 2009 23:38:46 +0200 Subject: 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). --- src/tail.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/tail.c') diff --git a/src/tail.c b/src/tail.c index 89c43b827..b3ebba9d6 100644 --- a/src/tail.c +++ b/src/tail.c @@ -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")); } -- cgit v1.2.3-54-g00ecf