Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh spins in endless loop with SIGHUP + read in zshexit
On Fri, 2021-05-14 at 10:56 +0100, Peter Stephenson wrote:
> > 3) exit (bin_break + BIN_EXIT)
> > 3a) in a shell function (ZEXIT_DEFERRED)
>
> Focussing on this one, I tried
>
> TRAPEXIT() { while true; do exit; done; }
>
> and sure enough the shell is looping forever if I kill the terminal.
> (Obviously, as written that's a daft thing to do, but with an appropriate
> set of internal conditions it might become realistic.)
>
> This is the sort of thing I was thinking about --- the answer is probably
> going to be along the lines of "breaks = loops" etc. in that condition
> at the top of zexit(), but I haven't made a patch as I suspect there's
> going to be more to the can of worms.
Actually, this seems to work and may be one of the less complicated
aspects of this.
pws
diff --git a/Src/builtin.c b/Src/builtin.c
index b7ceefd55..a29eb49e4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5828,8 +5828,11 @@ zexit(int val, enum zexit_t from_where)
* a later value always overrides an earlier.
*/
exit_val = val;
- if (shell_exiting == -1)
+ if (shell_exiting == -1) {
+ retflag = 1;
+ breaks = loops;
return;
+ }
if (isset(MONITOR) && !stopmsg && from_where != ZEXIT_SIGNAL) {
scanjobs(); /* check if jobs need printing */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author