From 2192f1003f27eaf523917a046a42d8fc0019a87b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 14 Jun 2009 22:26:52 -0400 Subject: [PATCH] Use inotify_init1 when available To avoid leaking the inotify fd. Fixes bug 585478. --- configure.in | 1 + gio/inotify/inotify-kernel.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 7a7ea9041..babd07c5d 100644 --- a/configure.in +++ b/configure.in @@ -1535,6 +1535,7 @@ inotify_support=no AC_CHECK_HEADERS([sys/inotify.h], [ inotify_support=yes + AC_CHECK_FUNCS(inotify_init1) ]) AM_CONDITIONAL(HAVE_INOTIFY, [test "$inotify_support" = "yes"]) diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c index f9861a0bd..b0b85ae4b 100644 --- a/gio/inotify/inotify-kernel.c +++ b/gio/inotify/inotify-kernel.c @@ -187,10 +187,15 @@ gboolean _ik_startup (void (*cb)(ik_event_t *event)) /* Ignore multi-calls */ if (initialized) return inotify_instance_fd >= 0; - + initialized = TRUE; + +#ifdef HAVE_INOTIFY_INIT1 + inotify_instance_fd = inotify_init1 (IN_CLOEXEC); +#else inotify_instance_fd = inotify_init (); - +#endif + if (inotify_instance_fd < 0) return FALSE;