[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 12/14] daemon: Close inotify handle on exit.



From: "Richard W.M. Jones" <rjones redhat com>

---
 daemon/inotify.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/daemon/inotify.c b/daemon/inotify.c
index e7ce423..add1f14 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -40,6 +40,17 @@ static int inotify_fd = -1;
 static char inotify_buf[64*1024*1024];	/* Event buffer, [0..posn-1] is valid */
 static size_t inotify_posn = 0;
 
+/* Clean up the inotify handle on daemon exit. */
+static void inotify_finalize (void) __attribute__((destructor));
+static void
+inotify_finalize (void)
+{
+  if (inotify_fd >= 0) {
+    close (inotify_fd);
+    inotify_fd = -1;
+  }
+}
+
 int
 optgroup_inotify_available (void)
 {
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]