wendy

wendy for debian packaging
git clone git://git.unixkoans.com/wendy.git
Log | Files | Refs | README | LICENSE

commit e5ce4d46a667ade7fc70dbf71579f7c4029943c7
parent 6a8cc070dbd404d740009f71bec92c8c3593cf2b
Author: z3bra <[email protected]>
Date:   Sun Feb 16 18:17:49 +0100

Now recreate the file watch when getting IN_IGNORED event

Diffstat:
wendy.c | 19++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/wendy.c b/wendy.c @@ -128,11 +128,14 @@ main (int argc, char **argv) if (fd < 0) perror("inotify_init"); +add_watch: /* add a watcher on the file */ wd = inotify_add_watch(fd, file, mask); - if (wd < 0) + if (wd < 0) { perror("inotify_add_watch"); + exit(1); + } if (!quiet) { printf( "watching file %s with event mask %u\n", file, mask); @@ -140,6 +143,7 @@ main (int argc, char **argv) /* start looping */ for (;;) { + /* get every event raised, and queue them */ len = read(fd, buf, BUF_LEN); @@ -149,15 +153,20 @@ main (int argc, char **argv) i = 0; - /* treat all events queued */ while (i < len) { /* get events one by one */ - ev = (struct inotify_event *) &buf[i]; + ev = (struct inotify_event *) &buf[i]; + + if (ev->mask & IN_IGNORED) { + printf("File watch removed. Recreating inotify watch\n"); + goto add_watch; + } - if (!quiet && ev->len > 0) { - printf("event on file %s: %u\n", ev->name, ev->mask); + if (!quiet) { + printf("event on file %s: %u\n", + ev->len ? ev->name : file, ev->mask); } /*