From d19e18c68d6415214afad37ce6cb47ec038ebe1c Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 28 Apr 2013 17:47:43 -0700 Subject: 31350: block SIGWINCH nearly all the time, except when about to calculate prompts or do synchronous read, so syscalls are not interrupted by window size changes. --- Src/utils.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Src/utils.c') diff --git a/Src/utils.c b/Src/utils.c index 26e2a5c2c..94ae52284 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1291,6 +1291,13 @@ preprompt(void) int period = getiparam("PERIOD"); int mailcheck = getiparam("MAILCHECK"); + /* + * Handle any pending window size changes before we compute prompts, + * then block them again to avoid interrupts during prompt display. + */ + winch_unblock(); + winch_block(); + if (isset(PROMPTSP) && isset(PROMPTCR) && !use_exit_printed && shout) { /* The PROMPT_SP heuristic will move the prompt down to a new line * if there was any dangling output on the line (assuming the terminal -- cgit v1.2.3 From b9e16ac81849a8bf13ca9674606b673733210bf5 Mon Sep 17 00:00:00 2001 From: joe M Date: Fri, 9 Aug 2013 14:54:29 -0500 Subject: 31648: fix timing errors in mailcheck --- ChangeLog | 4 ++++ Src/utils.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index b81522315..7065e309d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-08-10 Peter Stephenson + + * 31648: joe M: Src/utils.c: fix timing errors in mailcheck. + 2013-08-08 Peter Stephenson * Src/Zle/zle_tricky.c (inststrlen): 31644: the wrong length was 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); -- cgit v1.2.3 From 40a881569fed17177fbd73079dd4d3849517567c Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 11 Aug 2013 20:19:53 +0100 Subject: 31650: use zlong for mailcheck parameters to ensure range --- ChangeLog | 5 +++++ Src/utils.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'Src/utils.c') diff --git a/ChangeLog b/ChangeLog index 7065e309d..d27000788 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-08-11 Peter Stephenson + + * 31650: Src/utils.c: use zlong for mailcheck parameters to + ensure sufficient range. + 2013-08-10 Peter Stephenson * 31648: joe M: Src/utils.c: fix timing errors in mailcheck. diff --git a/Src/utils.c b/Src/utils.c index 6d9ffe350..d1d9406c2 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1289,8 +1289,8 @@ preprompt(void) static time_t lastperiodic; time_t currentmailcheck; LinkNode ln; - int period = getiparam("PERIOD"); - int mailcheck = getiparam("MAILCHECK"); + zlong period = getiparam("PERIOD"); + zlong mailcheck = getiparam("MAILCHECK"); /* * Handle any pending window size changes before we compute prompts, @@ -1338,7 +1338,7 @@ preprompt(void) /* If 1) the parameter PERIOD exists, 2) a hook function for * * "periodic" exists, 3) it's been greater than PERIOD since we * * executed any such hook, then execute it now. */ - if (period && (time(NULL) > lastperiodic + period) && + if (period && ((zlong)time(NULL) > (zlong)lastperiodic + period) && !callhookfunc("periodic", NULL, 1, NULL)) lastperiodic = time(NULL); if (errflag) @@ -1358,7 +1358,7 @@ preprompt(void) /* Check mail */ currentmailcheck = time(NULL); if (mailcheck && - (int) difftime(currentmailcheck, lastmailcheck) > mailcheck) { + (zlong) difftime(currentmailcheck, lastmailcheck) > mailcheck) { char *mailfile; if (mailpath && *mailpath && **mailpath) -- cgit v1.2.3