]> granicus.if.org Git - neomutt/commitdiff
add fallback for inotify_init1
authorGero Treuner <gero@70t.de>
Sun, 1 Sep 2019 14:58:46 +0000 (16:58 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 14 Oct 2019 10:45:56 +0000 (11:45 +0100)
Co-authored-by: Richard Russon <rich@flatcap.org>
auto.def
monitor.c
monitor.h

index c66d03d64dcf44584ca48fb530d5eddb2407b8a7..1b92e27db237643ba74f36ff0e0daccc9dffe67c 100644 (file)
--- a/auto.def
+++ b/auto.def
@@ -503,10 +503,10 @@ if {[get-define want-gpgme]} {
 ###############################################################################
 # INOTIFY
 if {[get-define want-inotify]} {
-  if {[cc-check-functions inotify_add_watch inotify_init1 inotify_rm_watch]} {
-    if {[cc-check-includes sys/inotify.h]} {
-      define USE_INOTIFY
-    }
+  if {[cc-check-functions inotify_add_watch inotify_init inotify_rm_watch]} {
+    define USE_INOTIFY
+    cc-check-functions inotify_init1
+    cc-check-includes sys/inotify.h
   }
 }
 
index 80e635209865af8cbb5820abc4e943b2d352536f..c9b6bf2223ffdbabe0ae779f8edabe248c46ef42 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -43,6 +43,9 @@
 #include "context.h"
 #include "curs_lib.h"
 #include "globals.h"
+#ifndef HAVE_INOTIFY_INIT1
+#include <fcntl.h>
+#endif
 
 bool MonitorFilesChanged = false;
 bool MonitorContextChanged = false;
@@ -154,12 +157,24 @@ static int monitor_init(void)
 {
   if (INotifyFd == -1)
   {
+#if HAVE_INOTIFY_INIT1
     INotifyFd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
     if (INotifyFd == -1)
     {
       mutt_debug(LL_DEBUG2, "inotify_init1 failed, errno=%d %s\n", errno, strerror(errno));
       return -1;
     }
+#else
+    INotifyFd = inotify_init();
+    if (INotifyFd == -1)
+    {
+      mutt_debug(LL_DEBUG2, "monitor: inotify_init failed, errno=%d %s\n",
+                 errno, strerror(errno));
+      return -1;
+    }
+    fcntl(INotifyFd, F_SETFL, O_NONBLOCK);
+    fcntl(INotifyFd, F_SETFD, FD_CLOEXEC);
+#endif
     mutt_poll_fd_add(0, POLLIN);
     mutt_poll_fd_add(INotifyFd, POLLIN);
   }
index d82a29a09338cbe98c0f1bca0a67025351dbdd9f..8d468e38f720ae6caa56978bb72f01cf22834e0b 100644 (file)
--- a/monitor.h
+++ b/monitor.h
@@ -3,7 +3,7 @@
  * Monitor files for changes
  *
  * @authors
- * Copyright (C) 2018 Gero Treuer <gero@70t.de>
+ * Copyright (C) 2018 Gero Treuner <gero@70t.de>
  *
  * @copyright
  * This program is free software: you can redistribute it and/or modify it under