[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inotify back end for tail -f on linux

From: Jim Meyering
Subject: Re: inotify back end for tail -f on linux
Date: Wed, 03 Jun 2009 17:17:55 +0200

Giuseppe Scrivano wrote:
> Thank you for all your suggestions, I'll keep them in mind.  I used your
> modified patch as my starting point.  I fixed the segfault problem and I
> added a new test case.

Thanks.  That's a definite improvement ;-)

However, my first manual test provoked this surprising diagnostic:

  $ touch k && src/tail -F k &
  src/tail: cannot watch parent directory of `k': No such file or directory

The following patch fixes that.
Go ahead and fold it into yours.

diff --git a/src/tail.c b/src/tail.c
index 4b2b59d..e71b080 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1185,12 +1185,11 @@ tail_forever_inotify (int wd, struct File_spec *f, int 
               size_t dirlen = dir_len (f[i].name);
               char prev = f[i].name[dirlen];
               f[i].basename_start = last_component (f[i].name) - f[i].name;
               f[i].name[dirlen] = '\0';

               /* Do not care if the directory was already added, in this
                  case the same watch descriptor will be returned.  */
-              f[i].parent_wd = inotify_add_watch (wd, f[i].name,
+              f[i].parent_wd = inotify_add_watch (wd, dirlen ? f[i].name : ".",
                                                   IN_CREATE | IN_MOVED_TO);

               f[i].name[dirlen] = prev;

Also, please adjust that comment:

               /* It's fine to add the same directory more than once.
                  In that case the same watch descriptor is returned.  */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]