hush: initial stab at brace expansion support
[oweals/busybox.git] / miscutils / inotifyd.c
index fdf2a2c2be678c31bdbc53364af21e87d07d9ffd..999b5e309f168b9b9eb370642acfdc82fdd79dd9 100644 (file)
@@ -34,8 +34,8 @@ static const char mask_names[] ALIGN1 =
        "a"     // 0x00000001   File was accessed
        "c"     // 0x00000002   File was modified
        "e"     // 0x00000004   Metadata changed
-       "w"     // 0x00000008   Writtable file was closed
-       "0"     // 0x00000010   Unwrittable file closed
+       "w"     // 0x00000008   Writable file was closed
+       "0"     // 0x00000010   Unwritable file closed
        "r"     // 0x00000020   File was opened
        "m"     // 0x00000040   File was moved from X
        "y"     // 0x00000080   File was moved to Y
@@ -53,9 +53,6 @@ enum {
        MASK_BITS = sizeof(mask_names) - 1
 };
 
-extern int inotify_init(void);
-extern int inotify_add_watch(int fd, const char *path, uint32_t mask);
-
 int inotifyd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int inotifyd_main(int argc, char **argv)
 {
@@ -160,9 +157,11 @@ int inotifyd_main(int argc, char **argv)
                                args[3] = ie->len ? ie->name : NULL;
                                wait4pid(xspawn((char **)args));
                                // we are done if all files got final x event
-                               if (ie->mask & 0x8000)
+                               if (ie->mask & 0x8000) {
                                        if (--argc <= 0)
                                                goto done;
+                                       inotify_rm_watch(pfd.fd, ie->wd);
+                               }
                        }
                        // next event
                        i = sizeof(struct inotify_event) + ie->len;