From: Marcela Mašláňová Date: Fri, 19 Jun 2009 13:47:02 +0000 (+0200) Subject: Option -i for disabling inotify support. X-Git-Tag: cronie1.4~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f38719403e54f7ab173a724fe7abef96cde627a;p=cronie Option -i for disabling inotify support. This option was based on email by user who can't set up daemon when they have mounted from NFS /var/spool/cron for a number of identical machines. Inotify pass the test because it find the directory, but didn't notice changes. http://linux-nfs.org/pipermail/nfsv4/2007-November/007127.html Thanks to: Alex Bame --- diff --git a/src/cron.c b/src/cron.c index c14aba5..8122dbe 100644 --- a/src/cron.c +++ b/src/cron.c @@ -43,6 +43,7 @@ sigchld_reaper(void), quit(int), parse_args(int c, char *v[]); static volatile sig_atomic_t got_sighup, got_sigchld; static int timeRunning, virtualTime, clockTime; static long GMToff; +static int DisableInotify = 0; #if defined WITH_INOTIFY @@ -102,6 +103,7 @@ void set_cron_watched(int fd) { static void handle_signals(cron_db * database) { if (got_sighup) { got_sighup = 0; + if (DisableInotify) #if defined WITH_INOTIFY /* watches must be reinstated on reload */ if (inotify_enabled) { @@ -122,7 +124,7 @@ static void handle_signals(cron_db * database) { static void usage(void) { const char **dflags; - fprintf(stderr, "usage: %s [-n] [-p] [-m ] [-x [", + fprintf(stderr, "usage: %s [-n] [-p] [-i] [-m ] [-x [", ProgramName); for (dflags = DebugFlagNames; *dflags; dflags++) fprintf(stderr, "%s%s", *dflags, dflags[1] ? "," : "]"); @@ -211,6 +213,9 @@ int main(int argc, char *argv[]) { (void) close(fd); } log_it("CRON", getpid(), "STARTUP", PACKAGE_VERSION, 0); + if (DisableInotify) + log_it("CRON", getpid(), "Switch off inotify - daemon runs with -i option", + "", 0); break; default: /* parent process should just die */ @@ -226,6 +231,8 @@ int main(int argc, char *argv[]) { load_database(&database); + + if (DisableInotify) #if defined WITH_INOTIFY for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) { /* initialize to negative number other than -1 @@ -271,6 +278,7 @@ int main(int argc, char *argv[]) { * clock. Classify the change into one of 4 cases. */ timeDiff = timeRunning - virtualTime; + if (DisableInotify) #if defined WITH_INOTIFY if (inotify_enabled) { check_inotify_database(&database); @@ -373,6 +381,7 @@ int main(int argc, char *argv[]) { handle_signals(&database); } + if (DisableInotify) #if defined WITH_INOTIFY if (inotify_enabled) set_cron_unwatched(fd); @@ -573,7 +582,7 @@ static void sigchld_reaper(void) { static void parse_args(int argc, char *argv[]) { int argch; - while (-1 != (argch = getopt(argc, argv, "npx:m:"))) { + while (-1 != (argch = getopt(argc, argv, "npix:m:"))) { switch (argch) { default: usage(); @@ -587,6 +596,10 @@ static void parse_args(int argc, char *argv[]) { case 'p': PermitAnyCrontab = 1; break; + case 'i': + inotify_enabled = 0; + DisableInotify = 1; + break; case 'm': strncpy(MailCmd, optarg, MAX_COMMAND); break;