wendy

inotify based node watcher
git clone git://git.2f30.org/wendy.git
Log | Files | Refs | README | LICENSE

commit 5cd21f9a20ee3dbd4d35d6957a5ebdb392ab8523
parent c3e9487830fe62b4adcf4ad22053485a435a1fac
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon,  2 Mar 2020 14:58:19 +0100

Free the malloc(), and ignore expected ENOTDIR error

Diffstat:
Mwendy.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/wendy.c b/wendy.c @@ -75,7 +75,11 @@ watch(int fd, char *pathname, int mask) w->wd = inotify_add_watch(fd, w->path, mask); if (w->wd < 0) { - perror(pathname); + /* triggered when dflag is set, so it is expected */ + if (errno != ENOTDIR) + perror(pathname); + + free(w); return NULL; } @@ -175,8 +179,10 @@ main (int argc, char **argv) */ if (e->mask & IN_IGNORED) { inotify_rm_watch(fd, e->wd); - if ((w->wd = inotify_add_watch(fd, w->path, mask)) < 0) + if ((w->wd = inotify_add_watch(fd, w->path, mask)) < 0) { SLIST_REMOVE(&head, w, watcher, entries); + free(w); + } } skip: