chiark / gitweb /
libudev: enumerate - scan /sys/module
[elogind.git] / udev / udevadm-settle.c
index 9492abd401e0dbb8f9efd193ac383d045139ac29..b17ba806d00a7ec33b79f002adcd91ec7d593cff 100644 (file)
@@ -153,7 +153,7 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
        if (pfd[0].fd < 0) {
                err(udev, "inotify_init failed: %m\n");
        } else {
-               if (inotify_add_watch(pfd[0].fd, udev_get_run_path(udev), IN_CLOSE_WRITE) < 0) {
+               if (inotify_add_watch(pfd[0].fd, udev_get_run_path(udev), IN_MOVED_TO) < 0) {
                        err(udev, "watching '%s' failed\n", udev_get_run_path(udev));
                        close(pfd[0].fd);
                        pfd[0].fd = -1;
@@ -183,8 +183,14 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[])
                }
 
                if (pfd[0].fd >= 0) {
-                       /* wake up once every second, or whenever the queue file gets gets closed */
-                       if (poll(pfd, 1, 1000) > 0 && pfd[0].revents & POLLIN) {
+                       int delay;
+
+                       if (exists != NULL || start > 0)
+                               delay = 100;
+                       else
+                               delay = 1000;
+                       /* wake up after delay, or immediately after the queue is rebuilt */
+                       if (poll(pfd, 1, delay) > 0 && pfd[0].revents & POLLIN) {
                                char buf[sizeof(struct inotify_event) + PATH_MAX];
 
                                read(pfd[0].fd, buf, sizeof(buf));