about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorjoe M <joe9mail@gmail.com>2013-08-09 14:54:29 -0500
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-08-10 19:48:13 +0100
commitb9e16ac81849a8bf13ca9674606b673733210bf5 (patch)
tree36919594244ec59aacf87374c37187ccf38cb7b6 /Src/utils.c
parent8ae8fae4001873515c2465ca05b8ac77a35a72e5 (diff)
downloadzsh-b9e16ac81849a8bf13ca9674606b673733210bf5.tar.gz
zsh-b9e16ac81849a8bf13ca9674606b673733210bf5.tar.xz
zsh-b9e16ac81849a8bf13ca9674606b673733210bf5.zip
31648: fix timing errors in mailcheck
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Src/utils.c b/Src/utils.c
index 94ae52284..6d9ffe350 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1287,6 +1287,7 @@ void
 preprompt(void)
 {
     static time_t lastperiodic;
+    time_t currentmailcheck;
     LinkNode ln;
     int period = getiparam("PERIOD");
     int mailcheck = getiparam("MAILCHECK");
@@ -1355,7 +1356,9 @@ preprompt(void)
 	return;
 
     /* Check mail */
-    if (mailcheck && (int) difftime(time(NULL), lastmailcheck) > mailcheck) {
+    currentmailcheck = time(NULL);
+    if (mailcheck &&
+	(int) difftime(currentmailcheck, lastmailcheck) > mailcheck) {
 	char *mailfile;
 
 	if (mailpath && *mailpath && **mailpath)
@@ -1371,7 +1374,7 @@ preprompt(void)
 	    }
 	    unqueue_signals();
 	}
-	lastmailcheck = time(NULL);
+	lastmailcheck = currentmailcheck;
     }
 
     if (prepromptfns) {
@@ -1431,7 +1434,7 @@ checkmailpath(char **s)
 	    }
 	} else if (shout) {
 	    if (st.st_size && st.st_atime <= st.st_mtime &&
-		st.st_mtime > lastmailcheck) {
+		st.st_mtime >= lastmailcheck) {
 		if (!u) {
 		    fprintf(shout, "You have new mail.\n");
 		    fflush(shout);