diff -bu2 ../cron-3.0.1-12-sav/cron.c ./cron.c --- ../cron-3.0.1-12-sav/cron.c 2003-06-10 11:23:10.000000000 +0200 +++ ./cron.c 2004-10-20 10:23:36.528399100 +0200 @@ -119,5 +119,9 @@ #ifdef __CYGWIN__ - { +# if DEBUGGING + if (!DebugFlags) { +# else + if (!dont_fork) { +# endif int fd; if ((fd = open("/dev/null", O_RDWR, 0)) != -1) @@ -264,5 +268,22 @@ getpid(), seconds_to_wait)) seconds_to_wait = (int) sleep((unsigned int) seconds_to_wait); + Debug(DSCH, ("[%d] returning from sleep. Returned value: %d\n", + getpid(), seconds_to_wait)); + + /* if we have to wait for a inordinate amount of time, this means + * that we somehow screwed up the timings. Most probable cause is + * that the clock was reset, or that the computer was put on sleep + * for some time. Let's recompute everything. + */ + if ((seconds_to_wait < 0) || (seconds_to_wait >= 90)) { + Debug(DSCH, ("[%d] Resyncing\n")); + cron_sync(); + seconds_to_wait = (int) (TargetTime - time((time_t*)0)); + Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n", + getpid(), TargetTime, seconds_to_wait)); } + + } + }