From: Gero Treuner Date: Sun, 1 Sep 2019 14:58:46 +0000 (+0200) Subject: add fallback for inotify_init1 X-Git-Tag: 2019-10-25~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42fcf7e538d1d358e22116c2c52e254384b77e8f;p=neomutt add fallback for inotify_init1 Co-authored-by: Richard Russon --- diff --git a/auto.def b/auto.def index c66d03d64..1b92e27db 100644 --- 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 } } diff --git a/monitor.c b/monitor.c index 80e635209..c9b6bf222 100644 --- 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 +#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); } diff --git a/monitor.h b/monitor.h index d82a29a09..8d468e38f 100644 --- a/monitor.h +++ b/monitor.h @@ -3,7 +3,7 @@ * Monitor files for changes * * @authors - * Copyright (C) 2018 Gero Treuer + * Copyright (C) 2018 Gero Treuner * * @copyright * This program is free software: you can redistribute it and/or modify it under