Bug 22516 - Ensure inotify fd is set close on exec
authorMatthias Clasen <mclasen@redhat.com>
Sat, 11 Jul 2009 00:10:12 +0000 (20:10 -0400)
committerColin Walters <walters@verbum.org>
Sat, 11 Jul 2009 00:11:22 +0000 (20:11 -0400)
This prevents it leaking into spawned child processes.

Signed-off-by: Colin Walters <walters@verbum.org>
bus/dir-watch-inotify.c
configure.in

index 3d8a666..f03e1bd 100644 (file)
@@ -98,7 +98,11 @@ bus_watch_directory (const char *dir, BusContext *context)
   _dbus_assert (dir != NULL);
 
   if (inotify_fd == -1) {
+#ifdef HAVE_INOTIFY_INIT1
+     inotify_fd = inotify_init1 (IN_CLOEXEC);
+#else
      inotify_fd = inotify_init ();
+#endif
      if (inotify_fd <= 0) {
       _dbus_warn ("Cannot initialize inotify\n");
       goto out;
index 3d15963..3af9cf7 100644 (file)
@@ -754,7 +754,7 @@ fi
 dnl check if inotify backend is enabled
 if test x$have_inotify = xyes; then
    AC_DEFINE(DBUS_BUS_ENABLE_INOTIFY,1,[Use inotify])
-
+   AC_CHECK_FUNCS(inotify_init1)
 fi
 
 AM_CONDITIONAL(DBUS_BUS_ENABLE_INOTIFY, test x$have_inotify = xyes)