1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

48857: declare "volatile" all globals that may be modified by signal handlers

This commit is contained in:
Bart Schaefer 2021-05-16 19:51:11 -07:00
parent 93b4ee524d
commit cf5c4828d1
7 changed files with 32 additions and 24 deletions

View file

@ -1,3 +1,9 @@
2021-05-16 Bart Schaefer <schaefer@zsh.org>
* 48857: Src/builtin.c, Src/exec.c, Src/loop.c, Src/makepro.awk,
Src/params.c, Src/signals.c: declare as "volatile" all globals
that may be modified by signal handlers; recognize in makepro.awk
2021-05-16 Oliver Kiddle <opk@zsh.org> 2021-05-16 Oliver Kiddle <opk@zsh.org>
* Jörg Sommer: users/26649: Completion/Unix/Command/_rake: * Jörg Sommer: users/26649: Completion/Unix/Command/_rake:

View file

@ -5635,13 +5635,16 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
*/ */
/**/ /**/
mod_export int mod_export volatile int exit_pending;
exit_pending;
/* Shell level at which we exit if exit_pending */ /* Shell level at which we exit if exit_pending */
/**/ /**/
mod_export int mod_export volatile int exit_level;
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 * /* break, bye, continue, exit, logout, return -- most of these take *
* one numeric argument, and the other (logout) is related to return. * * 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; 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 */ /* check to see if user has jobs running/stopped */
/**/ /**/

View file

@ -84,7 +84,7 @@ int nohistsave;
/* error flag: bits from enum errflag_bits */ /* 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. * State of trap return value. Value is from enum trap_state.
@ -122,7 +122,7 @@ int subsh;
/* != 0 if we have a return pending */ /* != 0 if we have a return pending */
/**/ /**/
mod_export int retflag; mod_export volatile int retflag;
/**/ /**/
long lastval2; long lastval2;
@ -1268,7 +1268,9 @@ execsimple(Estate state)
} else { } else {
int q = queue_signal_level(); int q = queue_signal_level();
dont_queue_signals(); dont_queue_signals();
if (code == WC_FUNCDEF) if (errflag)
lv = errflag;
else if (code == WC_FUNCDEF)
lv = execfuncdef(state, NULL); lv = execfuncdef(state, NULL);
else else
lv = (execfuncs[code - WC_CURSH])(state, 0); lv = (execfuncs[code - WC_CURSH])(state, 0);

View file

@ -43,7 +43,7 @@ mod_export int contflag;
/* # of break levels */ /* # of break levels */
/**/ /**/
mod_export int breaks; mod_export volatile int breaks;
/**/ /**/
int int

View file

@ -79,7 +79,7 @@ BEGIN {
break break
} }
sub(/^ */, "", line) 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) dtype = substr(line, 1, RLENGTH)
sub(/ *$/, "", dtype) sub(/ *$/, "", dtype)
if(" " dtype " " ~ / static /) if(" " dtype " " ~ / static /)

View file

@ -98,8 +98,10 @@ char *ifs, /* $IFS */
*pwd; /* $PWD */ *pwd; /* $PWD */
/**/ /**/
mod_export mod_export volatile zlong
zlong lastval, /* $? */ lastval; /* $? */
/**/
mod_export zlong
mypid, /* $$ */ mypid, /* $$ */
lastpid, /* $! */ lastpid, /* $! */
zterm_columns, /* $COLUMNS */ zterm_columns, /* $COLUMNS */

View file

@ -53,7 +53,7 @@ mod_export Eprog siglists[VSIGCOUNT];
/* Total count of trapped signals */ /* Total count of trapped signals */
/**/ /**/
mod_export int nsigtrapped; mod_export volatile int nsigtrapped;
/* Running an exit trap? */ /* Running an exit trap? */
@ -72,20 +72,20 @@ static int exit_trap_posix;
/* Variables used by signal queueing */ /* 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 int signal_queue[MAX_QUEUE_SIZE];
/**/ /**/
mod_export sigset_t signal_mask_queue[MAX_QUEUE_SIZE]; mod_export sigset_t signal_mask_queue[MAX_QUEUE_SIZE];
#ifdef DEBUG #ifdef DEBUG
/**/ /**/
mod_export int queue_in; mod_export volatile int queue_in;
#endif #endif
/* Variables used by trap queueing */ /* 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]; mod_export int trap_queue[MAX_QUEUE_SIZE];
@ -672,9 +672,9 @@ zhandler(int sig)
if ((isset(PRIVILEGED) || isset(RESTRICTED)) && if ((isset(PRIVILEGED) || isset(RESTRICTED)) &&
isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL)) isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL))
zexit(SIGINT, ZEXIT_SIGNAL); zexit(SIGINT, ZEXIT_SIGNAL);
errflag |= ERRFLAG_INT;
if (list_pipe || chline || simple_pline) { if (list_pipe || chline || simple_pline) {
breaks = loops; breaks = loops;
errflag |= ERRFLAG_INT;
inerrflush(); inerrflush();
check_cursh_sig(SIGINT); check_cursh_sig(SIGINT);
} }
@ -1266,19 +1266,19 @@ unqueue_traps(void)
/* Are we already executing a trap? */ /* Are we already executing a trap? */
/**/ /**/
int intrap; volatile int intrap;
/* Is the current trap a function? */ /* Is the current trap a function? */
/**/ /**/
int trapisfunc; volatile int trapisfunc;
/* /*
* If the current trap is not a function, at what function depth * If the current trap is not a function, at what function depth
* did the trap get called? * did the trap get called?
*/ */
/**/ /**/
int traplocallevel; volatile int traplocallevel;
/* /*
* sig is the signal number. * sig is the signal number.