diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Modules/zpty.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 4 | ||||
-rw-r--r-- | Src/builtin.c | 24 | ||||
-rw-r--r-- | Src/exec.c | 2 | ||||
-rw-r--r-- | Src/init.c | 10 | ||||
-rw-r--r-- | Src/signals.c | 8 | ||||
-rw-r--r-- | Src/subst.c | 2 | ||||
-rw-r--r-- | Src/zsh.h | 8 |
8 files changed, 35 insertions, 25 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 2f83f7ce6..45fd15ee0 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -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) { diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 27dc8ef21..22cb21be3 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -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 */ diff --git a/Src/builtin.c b/Src/builtin.c index 00b5d5c50..5fe5ea6d1 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -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); diff --git a/Src/exec.c b/Src/exec.c index 64eee7dc4..0d9d7de7c 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -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); } } diff --git a/Src/init.c b/Src/init.c index 2306d7bdf..2e2ef881c 100644 --- a/Src/init.c +++ b/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 diff --git a/Src/signals.c b/Src/signals.c index 14218177a..96ff9e9b3 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -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; diff --git a/Src/subst.c b/Src/subst.c index f887dbd24..79efc9ad2 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -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); } diff --git a/Src/zsh.h b/Src/zsh.h index 9194ea82c..657e6d8ec 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -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) |