chiark / gitweb /
use CLOEXEC flags instead of fcntl()
[elogind.git] / udev / udev-watch.c
index 5a49c963da82a0651aa50c7612580419abc063c6..d67083b51b3a67e3d14f9d2a7b6b4ef5113646a2 100644 (file)
@@ -38,10 +38,8 @@ static int inotify_fd = -1;
  */
 int udev_watch_init(struct udev *udev)
 {
  */
 int udev_watch_init(struct udev *udev)
 {
-       inotify_fd = inotify_init();
-       if (inotify_fd >= 0)
-               util_set_fd_cloexec(inotify_fd);
-       else
+       inotify_fd = inotify_init1(IN_CLOEXEC);
+       if (inotify_fd < 0)
                err(udev, "inotify_init failed: %m\n");
        return inotify_fd;
 }
                err(udev, "inotify_init failed: %m\n");
        return inotify_fd;
 }
@@ -121,6 +119,7 @@ void udev_watch_begin(struct udev *udev, struct udev_device *dev)
        if (wd < 0) {
                err(udev, "inotify_add_watch(%d, %s, %o) failed: %m\n",
                    inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
        if (wd < 0) {
                err(udev, "inotify_add_watch(%d, %s, %o) failed: %m\n",
                    inotify_fd, udev_device_get_devnode(dev), IN_CLOSE_WRITE);
+               return;
        }
 
        snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd);
        }
 
        snprintf(filename, sizeof(filename), "%s/.udev/watch/%d", udev_get_dev_path(udev), wd);