mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 15:01:21 +02:00
45058: internal: Add symbolic names to possible values of zexit()'s "from_where" parameter. No functional change.
This commit is contained in:
parent
2cb15a23f8
commit
8bc4400762
@ -1,5 +1,10 @@
|
||||
2019-12-17 Daniel Shahaf <danielsh@apache.org>
|
||||
|
||||
* 45058: Src/Modules/zpty.c, Src/Zle/zle_main.c, Src/builtin.c,
|
||||
Src/exec.c, Src/init.c, Src/signals.c, Src/subst.c, Src/zsh.h:
|
||||
internal: Add symbolic names to possible values of zexit()'s
|
||||
"from_where" parameter. No functional change.
|
||||
|
||||
* unposted: Src/builtin.c: Update comment to reflect variable
|
||||
rename in 41012 (zsh-5.3.1-182-gd7110d8f0).
|
||||
|
||||
|
@ -426,7 +426,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
|
||||
execode(prog, 1, 0, "zpty");
|
||||
stopmsg = 2;
|
||||
mypid = 0; /* trick to ensure we _exit() */
|
||||
zexit(lastval, 0);
|
||||
zexit(lastval, ZEXIT_NORMAL);
|
||||
}
|
||||
master = movefd(master);
|
||||
if (master == -1) {
|
||||
|
@ -905,7 +905,7 @@ getbyte(long do_keytmout, int *timeout, int full)
|
||||
if ((zlereadflags & ZLRF_IGNOREEOF) && icnt++ < 20)
|
||||
continue;
|
||||
stopmsg = 1;
|
||||
zexit(1, 0);
|
||||
zexit(1, ZEXIT_NORMAL);
|
||||
}
|
||||
icnt = 0;
|
||||
if (errno == EINTR) {
|
||||
@ -928,7 +928,7 @@ getbyte(long do_keytmout, int *timeout, int full)
|
||||
} else if (errno != 0) {
|
||||
zerr("error on TTY read: %e", errno);
|
||||
stopmsg = 1;
|
||||
zexit(1, 0);
|
||||
zexit(1, ZEXIT_NORMAL);
|
||||
}
|
||||
}
|
||||
if (cc == '\r') /* undo the exchange of \n and \r determined by */
|
||||
|
@ -5665,7 +5665,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
|
||||
}
|
||||
return lastval;
|
||||
}
|
||||
zexit(num, 0); /* else treat return as logout/exit */
|
||||
zexit(num, ZEXIT_NORMAL); /* else treat return as logout/exit */
|
||||
break;
|
||||
case BIN_LOGOUT:
|
||||
if (unset(LOGINSHELL)) {
|
||||
@ -5687,7 +5687,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
|
||||
* If we are already exiting... give this all up as
|
||||
* a bad job.
|
||||
*/
|
||||
if (stopmsg || (zexit(0,2), !stopmsg)) {
|
||||
if (stopmsg || (zexit(0, ZEXIT_DEFERRED), !stopmsg)) {
|
||||
retflag = 1;
|
||||
breaks = loops;
|
||||
exit_pending = 1;
|
||||
@ -5695,7 +5695,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
|
||||
exit_val = num;
|
||||
}
|
||||
} else
|
||||
zexit(num, 0);
|
||||
zexit(num, ZEXIT_NORMAL);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@ -5780,14 +5780,15 @@ _realexit(void)
|
||||
|
||||
/* exit the shell. val is the return value of the shell. *
|
||||
* from_where is
|
||||
* 1 if zexit is called because of a signal
|
||||
* 2 if we can't actually exit yet (e.g. functions need
|
||||
* terminating) but should perform the usual interactive tests.
|
||||
* ZEXIT_SIGNAL if zexit is called because of a signal
|
||||
* ZEXIT_DEFERRED if we can't actually exit yet (e.g., functions need
|
||||
* terminating) but should perform the usual interactive
|
||||
* tests.
|
||||
*/
|
||||
|
||||
/**/
|
||||
mod_export void
|
||||
zexit(int val, int from_where)
|
||||
zexit(int val, enum zexit_t from_where)
|
||||
{
|
||||
/*
|
||||
* Don't do anything recursively: see below.
|
||||
@ -5798,7 +5799,7 @@ zexit(int val, int from_where)
|
||||
if (shell_exiting == -1)
|
||||
return;
|
||||
|
||||
if (isset(MONITOR) && !stopmsg && from_where != 1) {
|
||||
if (isset(MONITOR) && !stopmsg && from_where != ZEXIT_SIGNAL) {
|
||||
scanjobs(); /* check if jobs need printing */
|
||||
if (isset(CHECKJOBS))
|
||||
checkjobs(); /* check if any jobs are running/stopped */
|
||||
@ -5808,7 +5809,8 @@ zexit(int val, int from_where)
|
||||
}
|
||||
}
|
||||
/* Positive shell_exiting means we have been here before */
|
||||
if (from_where == 2 || (shell_exiting++ && from_where))
|
||||
if (from_where == ZEXIT_DEFERRED ||
|
||||
(shell_exiting++ && from_where != ZEXIT_NORMAL))
|
||||
return;
|
||||
|
||||
/*
|
||||
@ -5824,12 +5826,12 @@ zexit(int val, int from_where)
|
||||
|
||||
if (isset(MONITOR)) {
|
||||
/* send SIGHUP to any jobs left running */
|
||||
killrunjobs(from_where == 1);
|
||||
killrunjobs(from_where == ZEXIT_SIGNAL);
|
||||
}
|
||||
if (isset(RCS) && interact) {
|
||||
if (!nohistsave) {
|
||||
int writeflags = HFILE_USE_OPTIONS;
|
||||
if (from_where == 1)
|
||||
if (from_where == ZEXIT_SIGNAL)
|
||||
writeflags |= HFILE_NO_REWRITE;
|
||||
saveandpophiststack(1, writeflags);
|
||||
savehistfile(NULL, 1, writeflags);
|
||||
|
@ -5949,7 +5949,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
|
||||
* exit command was handled.
|
||||
*/
|
||||
stopmsg = 1;
|
||||
zexit(exit_val, 0);
|
||||
zexit(exit_val, ZEXIT_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
10
Src/init.c
10
Src/init.c
@ -161,7 +161,7 @@ loop(int toplevel, int justonce)
|
||||
* Handle that now.
|
||||
*/
|
||||
stopmsg = 1;
|
||||
zexit(exit_val, 0);
|
||||
zexit(exit_val, ZEXIT_NORMAL);
|
||||
}
|
||||
if (tok == LEXERR && !lastval)
|
||||
lastval = 1;
|
||||
@ -1371,7 +1371,7 @@ init_misc(char *cmd, char *zsh_name)
|
||||
bshin = fdopen(SHIN, "r");
|
||||
execstring(cmd, 0, 1, "cmdarg");
|
||||
stopmsg = 1;
|
||||
zexit((exit_pending || shell_exiting) ? exit_val : lastval, 0);
|
||||
zexit((exit_pending || shell_exiting) ? exit_val : lastval, ZEXIT_NORMAL);
|
||||
}
|
||||
|
||||
if (interact && isset(RCS))
|
||||
@ -1778,20 +1778,20 @@ zsh_main(UNUSED(int argc), char **argv)
|
||||
if (!lastval)
|
||||
lastval = 1;
|
||||
stopmsg = 1;
|
||||
zexit(lastval, 0);
|
||||
zexit(lastval, ZEXIT_NORMAL);
|
||||
}
|
||||
if (!(isset(IGNOREEOF) && interact)) {
|
||||
#if 0
|
||||
if (interact)
|
||||
fputs(islogin ? "logout\n" : "exit\n", shout);
|
||||
#endif
|
||||
zexit(lastval, 0);
|
||||
zexit(lastval, ZEXIT_NORMAL);
|
||||
continue;
|
||||
}
|
||||
noexitct++;
|
||||
if (noexitct >= 10) {
|
||||
stopmsg = 1;
|
||||
zexit(lastval, 0);
|
||||
zexit(lastval, ZEXIT_NORMAL);
|
||||
}
|
||||
/*
|
||||
* Don't print the message if it was already handled by
|
||||
|
@ -654,7 +654,7 @@ zhandler(int sig)
|
||||
_exit(SIGPIPE);
|
||||
else if (!isatty(SHTTY)) {
|
||||
stopmsg = 1;
|
||||
zexit(SIGPIPE, 1);
|
||||
zexit(SIGPIPE, ZEXIT_SIGNAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -662,7 +662,7 @@ zhandler(int sig)
|
||||
case SIGHUP:
|
||||
if (!handletrap(SIGHUP)) {
|
||||
stopmsg = 1;
|
||||
zexit(SIGHUP, 1);
|
||||
zexit(SIGHUP, ZEXIT_SIGNAL);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -670,7 +670,7 @@ zhandler(int sig)
|
||||
if (!handletrap(SIGINT)) {
|
||||
if ((isset(PRIVILEGED) || isset(RESTRICTED)) &&
|
||||
isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL))
|
||||
zexit(SIGINT, 1);
|
||||
zexit(SIGINT, ZEXIT_SIGNAL);
|
||||
if (list_pipe || chline || simple_pline) {
|
||||
breaks = loops;
|
||||
errflag |= ERRFLAG_INT;
|
||||
@ -703,7 +703,7 @@ zhandler(int sig)
|
||||
errflag = noerrs = 0;
|
||||
zwarn("timeout");
|
||||
stopmsg = 1;
|
||||
zexit(SIGALRM, 1);
|
||||
zexit(SIGALRM, ZEXIT_SIGNAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -3044,7 +3044,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
|
||||
* shouldn't be any if not interactive.
|
||||
*/
|
||||
stopmsg = 1;
|
||||
zexit(1, 0);
|
||||
zexit(1, ZEXIT_NORMAL);
|
||||
} else
|
||||
_exit(1);
|
||||
}
|
||||
|
@ -3222,6 +3222,14 @@ enum {
|
||||
/* Hooks in core. */
|
||||
/***************************************/
|
||||
|
||||
/* The type of zexit()'s second parameter, which see. */
|
||||
enum zexit_t {
|
||||
/* This isn't a bitfield. The values are here just for explicitness. */
|
||||
ZEXIT_NORMAL = 0,
|
||||
ZEXIT_SIGNAL = 1,
|
||||
ZEXIT_DEFERRED = 2
|
||||
};
|
||||
|
||||
#define EXITHOOK (zshhooks + 0)
|
||||
#define BEFORETRAPHOOK (zshhooks + 1)
|
||||
#define AFTERTRAPHOOK (zshhooks + 2)
|
||||
|
Loading…
Reference in New Issue
Block a user