Currently, if the system clock is set backwards, ksh won't check for new mail until the clock ticks up to when it would have checked for new mail absent the jump.
Measuring $MAILCHECK with the monotonic clock fixes this. I think checking mlastchkd == 0 to determine if this is the first run is a hack so I added an explicit flag. ok? -- Scott Cheloha Index: bin/ksh/mail.c =================================================================== RCS file: /cvs/src/bin/ksh/mail.c,v retrieving revision 1.23 diff -u -p -r1.23 mail.c --- bin/ksh/mail.c 9 Apr 2018 17:53:36 -0000 1.23 +++ bin/ksh/mail.c 24 Jun 2018 21:22:28 -0000 @@ -6,6 +6,7 @@ */ #include <sys/stat.h> +#include <sys/time.h> #include <string.h> #include <time.h> @@ -30,7 +31,7 @@ typedef struct mbox { static mbox_t *mplist; static mbox_t mbox; -static time_t mlastchkd; /* when mail was last checked */ +static struct timespec mlastchkd; /* when mail was last checked */ static time_t mailcheck_interval; static void munset(mbox_t *); /* free mlist and mval */ @@ -41,14 +42,18 @@ void mcheck(void) { mbox_t *mbp; - time_t now; + struct timespec elapsed, now; struct tbl *vp; struct stat stbuf; + static int first = 1; - now = time(NULL); - if (mlastchkd == 0) + clock_gettime(CLOCK_MONOTONIC, &now); + if (first) { mlastchkd = now; - if (now - mlastchkd >= mailcheck_interval) { + first = 0; + } + timespecsub(&now, &mlastchkd, &elapsed); + if (elapsed.tv_sec >= mailcheck_interval) { mlastchkd = now; if (mplist)