Pádraig Brady wrote: > Jim Meyering wrote: >> Pádraig Brady wrote: >>> Subject: [PATCH] tail: fix tail -f failure when inotify used >>> >>> * src/tail.c (tail_inotify_forever): Use the correct bounds >>> in the error check of the return from inotify_add_watch(). >>> Reported by C de-Avillez. >>> --- >>> src/tail.c | 2 +- >>> 1 files changed, 1 insertions(+), 1 deletions(-) >>> >>> diff --git a/src/tail.c b/src/tail.c >>> index 3c8f425..7d84bec 100644 >>> --- a/src/tail.c >>> +++ b/src/tail.c >>> @@ -1231,7 +1231,7 @@ tail_forever_inotify (int wd, struct File_spec *f, >>> size_t n_files, >>> if (hash_insert (wd_table, &(f[i])) == NULL) >>> xalloc_die (); >>> >>> - if (follow_mode == Follow_name || f[i].wd) >>> + if (follow_mode == Follow_name || 0 <= f[i].wd) >> >> Ten lines above that, we ensure that 0 <= f[i].wd is true, >> so this stmt: >> if (follow_mode == Follow_name || 0 <= f[i].wd) >> is equivalent to this: >> if (follow_mode == Follow_name || true) >> aka, >> if (true) >> >> so perhaps that change should be larger: >> >> - if (follow_mode == Follow_name || f[i].wd) >> - found_watchable = true; >> + found_watchable = true; >> >> Also, the initialization (farther above) of f[i].wd to a valid >> file descriptor value (0) seems like a mistake: >> >> - f[i].wd = 0; >> + f[i].wd = -1; >> >> What do you think? >> > > Agreed. I'll push the attached soon.
Perfect. Thanks.