]> granicus.if.org Git - cronie/commitdiff
Option -i for disabling inotify support.
authorMarcela Mašláňová <mmaslano@redhat.com>
Fri, 19 Jun 2009 13:47:02 +0000 (15:47 +0200)
committerMarcela Mašláňová <mmaslano@redhat.com>
Fri, 19 Jun 2009 13:47:02 +0000 (15:47 +0200)
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

src/cron.c

index c14aba58b8ef2e55663cd9b22b29c8a59d152ba2..8122dbe13d90393055c942bbd6bcaa3cf69939c4 100644 (file)
@@ -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 <mail command>] [-x [",
+       fprintf(stderr, "usage:  %s [-n] [-p] [-i] [-m <mail command>] [-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;