zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: "Jörg Sommer" <joerg@jo-so.de>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Zsh spins in endless loop with SIGHUP + read in zshexit
Date: Thu, 13 May 2021 08:54:06 -0700	[thread overview]
Message-ID: <CAH+w=7ZUJ_WMjJzx-fcwEVigji-nkLfRRdoWGgS8rpwiXck7Eg@mail.gmail.com> (raw)
In-Reply-To: <20210513101751.j5vo2dbrd5uzwju4@jo-so.de>

On Thu, May 13, 2021 at 3:18 AM Jörg Sommer <joerg@jo-so.de> wrote:
>
> I'm using `read` in `zshexit` and when my terminal crashes (e.g. XTerm gets
> killed or ssh connection dies) Zsh spins in an endless loop until I kill it
> with SIGKILL (SIGTERM doesn't work).
> [...]
>
> So, if `raw_getbyte` returns `0` `zexit` gets called again. I think this
> causes the loop.

Yep.  zexit() is a no-op there because it doesn't allow itself to
execute recursively.

There might be other places where similar loops can be triggered.  I
see just now PWS has also produced a different patch, which requires
that zexit() return a value; I have no opinion on whether that's
actually preferable.

diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 0561c3b3b..9edf30e01 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -906,6 +906,8 @@ getbyte(long do_keytmout, int *timeout, int full)
             continue;
         stopmsg = 1;
         zexit(1, ZEXIT_NORMAL);
+        /* If called from an exit hook, zexit() returns, so: */
+        break;
         }
         icnt = 0;
         if (errno == EINTR) {
@@ -929,6 +931,8 @@ getbyte(long do_keytmout, int *timeout, int full)
         zerr("error on TTY read: %e", errno);
         stopmsg = 1;
         zexit(1, ZEXIT_NORMAL);
+        /* If called from an exit hook, zexit() returns, so: */
+        break;
         }
     }
     if (cc == '\r')        /* undo the exchange of \n and \r determined by */


  parent reply	other threads:[~2021-05-13 15:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 10:17 Jörg Sommer
2021-05-13 14:36 ` Daniel Shahaf
2021-07-18 19:11   ` Lawrence Velázquez
2021-07-27  3:14     ` Daniel Shahaf
2021-05-13 15:51 ` Peter Stephenson
2021-05-13 15:54 ` Bart Schaefer [this message]
2021-05-13 16:07   ` Peter Stephenson
2021-05-13 16:30     ` Bart Schaefer
2021-05-13 18:44       ` Peter Stephenson
2021-05-13 21:37         ` Bart Schaefer
2021-05-14  9:56           ` Peter Stephenson
2021-05-14 17:44             ` Peter Stephenson
2021-05-14 18:51             ` Bart Schaefer

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=7ZUJ_WMjJzx-fcwEVigji-nkLfRRdoWGgS8rpwiXck7Eg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=joerg@jo-so.de \
    --cc=zsh-users@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).