* src/tail.c (tail_forever_inotify): Avoid modifying fdspec->wd while
it is in the wd_to_name hash table. Once it is removed, it can be
added using the new `wd' as key for the hash table. This fixes the
abort-inducing bug reported by Rob Wortman in
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/19372
continue;
/* It's fine to add the same file more than once. */
- f[j].wd = inotify_add_watch (wd, f[j].name, inotify_wd_mask);
-
- if (f[j].wd < 0)
+ int new_wd = inotify_add_watch (wd, f[j].name, inotify_wd_mask);
+ if (new_wd < 0)
{
error (0, errno, _("cannot watch %s"), quote (f[j].name));
continue;
}
fspec = &(f[j]);
+
+ /* Remove `fspec' and re-add it using `new_fd' as its key. */
+ hash_delete (wd_to_name, fspec);
+ fspec->wd = new_wd;
if (hash_insert (wd_to_name, fspec) == NULL)
xalloc_die ();