From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] volatile declarations (was Re: 'while do done' hangs interactive zsh)
Date: Sun, 16 May 2021 14:19:06 -0700 [thread overview]
Message-ID: <CAH+w=7a567o1p+_N_PedQve5B9-Ow3Wkkvv=d-4bvQxborDJtQ@mail.gmail.com> (raw)
In-Reply-To: <8432cc50e13a26a96e78a039a922d3343ab1f509.camel@ntlworld.com>
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
On Sun, May 16, 2021 at 1:34 PM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> I think we lost the pre-ISO world some time ago now. I can't believe
> "volatile" is a problem.
OK, see attached. I hope I haven't missed any.
[-- Attachment #2: volatile.txt --]
[-- Type: text/plain, Size: 4906 bytes --]
diff --git a/Src/builtin.c b/Src/builtin.c
index a29eb49e4..a16fddcb7 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5635,13 +5635,16 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
*/
/**/
-mod_export int
-exit_pending;
+mod_export volatile int exit_pending;
/* Shell level at which we exit if exit_pending */
/**/
-mod_export int
-exit_level;
+mod_export volatile int exit_level;
+
+/* we have printed a 'you have stopped (running) jobs.' message */
+
+/**/
+mod_export volatile int stopmsg;
/* break, bye, continue, exit, logout, return -- most of these take *
* one numeric argument, and the other (logout) is related to return. *
@@ -5733,11 +5736,6 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
return 0;
}
-/* we have printed a 'you have stopped (running) jobs.' message */
-
-/**/
-mod_export int stopmsg;
-
/* check to see if user has jobs running/stopped */
/**/
diff --git a/Src/exec.c b/Src/exec.c
index 6f09e0d9f..49ff88b80 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -84,7 +84,7 @@ int nohistsave;
/* error flag: bits from enum errflag_bits */
/**/
-mod_export int errflag;
+mod_export volatile int errflag;
/*
* State of trap return value. Value is from enum trap_state.
@@ -122,7 +122,7 @@ int subsh;
/* != 0 if we have a return pending */
/**/
-mod_export int retflag;
+mod_export volatile int retflag;
/**/
long lastval2;
@@ -1268,7 +1268,9 @@ execsimple(Estate state)
} else {
int q = queue_signal_level();
dont_queue_signals();
- if (code == WC_FUNCDEF)
+ if (errflag)
+ lv = errflag;
+ else if (code == WC_FUNCDEF)
lv = execfuncdef(state, NULL);
else
lv = (execfuncs[code - WC_CURSH])(state, 0);
diff --git a/Src/loop.c b/Src/loop.c
index aa733a2cb..db5b3e097 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -43,7 +43,7 @@ mod_export int contflag;
/* # of break levels */
/**/
-mod_export int breaks;
+mod_export volatile int breaks;
/**/
int
diff --git a/Src/makepro.awk b/Src/makepro.awk
index 226d3f96b..f69660531 100644
--- a/Src/makepro.awk
+++ b/Src/makepro.awk
@@ -79,7 +79,7 @@ BEGIN {
break
}
sub(/^ */, "", line)
- match(line, /^((const|enum|mod_export|static|struct|union) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/)
+ match(line, /^((const|enum|mod_export|static|struct|union|volatile) +)*([_0-9A-Za-z]+ +|((char|double|float|int|long|short|unsigned|void) +)+)((const|static) +)*/)
dtype = substr(line, 1, RLENGTH)
sub(/ *$/, "", dtype)
if(" " dtype " " ~ / static /)
diff --git a/Src/params.c b/Src/params.c
index 20dfb5b5f..4f6b361f9 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -98,8 +98,10 @@ char *ifs, /* $IFS */
*pwd; /* $PWD */
/**/
-mod_export
-zlong lastval, /* $? */
+mod_export volatile zlong
+ lastval; /* $? */
+/**/
+mod_export zlong
mypid, /* $$ */
lastpid, /* $! */
zterm_columns, /* $COLUMNS */
diff --git a/Src/signals.c b/Src/signals.c
index 4adf03202..2c540f38f 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -53,7 +53,7 @@ mod_export Eprog siglists[VSIGCOUNT];
/* Total count of trapped signals */
/**/
-mod_export int nsigtrapped;
+mod_export volatile int nsigtrapped;
/* Running an exit trap? */
@@ -72,20 +72,20 @@ static int exit_trap_posix;
/* Variables used by signal queueing */
/**/
-mod_export int queueing_enabled, queue_front, queue_rear;
+mod_export volatile int queueing_enabled, queue_front, queue_rear;
/**/
mod_export int signal_queue[MAX_QUEUE_SIZE];
/**/
mod_export sigset_t signal_mask_queue[MAX_QUEUE_SIZE];
#ifdef DEBUG
/**/
-mod_export int queue_in;
+mod_export volatile int queue_in;
#endif
/* Variables used by trap queueing */
/**/
-mod_export int trap_queueing_enabled, trap_queue_front, trap_queue_rear;
+mod_export volatile int trap_queueing_enabled, trap_queue_front, trap_queue_rear;
/**/
mod_export int trap_queue[MAX_QUEUE_SIZE];
@@ -672,9 +672,9 @@ zhandler(int sig)
if ((isset(PRIVILEGED) || isset(RESTRICTED)) &&
isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL))
zexit(SIGINT, ZEXIT_SIGNAL);
+ errflag |= ERRFLAG_INT;
if (list_pipe || chline || simple_pline) {
breaks = loops;
- errflag |= ERRFLAG_INT;
inerrflush();
check_cursh_sig(SIGINT);
}
@@ -1266,19 +1266,19 @@ unqueue_traps(void)
/* Are we already executing a trap? */
/**/
-int intrap;
+volatile int intrap;
/* Is the current trap a function? */
/**/
-int trapisfunc;
+volatile int trapisfunc;
/*
* If the current trap is not a function, at what function depth
* did the trap get called?
*/
/**/
-int traplocallevel;
+volatile int traplocallevel;
/*
* sig is the signal number.
next prev parent reply other threads:[~2021-05-16 21:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-16 9:16 'while do done' hangs interactive zsh Arseny Maslennikov
2021-05-16 14:28 ` Bart Schaefer
2021-05-16 15:46 ` Bart Schaefer
2021-05-16 16:15 ` Mikael Magnusson
2021-05-16 16:22 ` Lawrence Velázquez
2021-05-16 17:47 ` Bart Schaefer
2021-05-16 18:23 ` Martijn Dekker
2021-05-16 19:59 ` Bart Schaefer
2021-05-16 20:34 ` Peter Stephenson
2021-05-16 21:19 ` Bart Schaefer [this message]
2021-05-16 23:40 ` [PATCH] volatile declarations (was Re: 'while do done' hangs interactive zsh) Martijn Dekker
2021-05-16 16:43 ` 'while do done' hangs interactive zsh Stephane Chazelas
2021-05-16 18:02 ` Bart Schaefer
2021-05-16 18:25 ` Martijn Dekker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7a567o1p+_N_PedQve5B9-Ow3Wkkvv=d-4bvQxborDJtQ@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).