zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Arseny Maslennikov <ar@cs.msu.ru>
Subject: Re: 'while do done' hangs interactive zsh
Date: Sun, 16 May 2021 10:47:18 -0700	[thread overview]
Message-ID: <CAH+w=7YOf2eWnB_0GO_ZhPSWP285Fz-YpBr7O7ZTfp+-XP=QLg@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3SHxn0hdsnTfOA3c9Hj=7q-nPCVAb1MEgS9MFtu-Ea=dA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

On Sun, May 16, 2021 at 9:15 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On 5/16/21, Bart Schaefer <schaefer@brasslantern.com> wrote:
> > Specifically, the shell is interruptible by ^C.
>
> I just updated to latest git and I still can't ^C the "while do;
> done".

Curious.

> > The attached makes both "while do" and "do done" into parse errors;
>
> I use "do done" in production code so you can't remove that.

Let's try the attached, then?

I don't immediately see any reason that the SIGINT handler should not
always set errflag.

> > Because we're still in the parser, none of (list_pipe || chline ||
> > simple_pline) is true, so we never set breaks or errflag, only
> > lastval.  I'm not immediately sure what to do about that; perhaps just
> > move the errflag setting outside that test?

However, setting errflag is not sufficient to actually interrupt the
parse.  The attached just causes the empty loop condition to fail when
signaled.  Which I suppose could mean there's still a race condition
if the interrupt occurs during the empty loop body instead.

[-- Attachment #2: exec-errflag.txt --]
[-- Type: text/plain, Size: 934 bytes --]

diff --git a/Src/exec.c b/Src/exec.c
index 6f09e0d9f..4575aa830 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1268,7 +1268,9 @@ execsimple(Estate state)
     } else {
 	int q = queue_signal_level();
 	dont_queue_signals();
-	if (code == WC_FUNCDEF)
+	if (errflag)
+	    lv = errflag;
+	else if (code == WC_FUNCDEF)
 	    lv = execfuncdef(state, NULL);
 	else
 	    lv = (execfuncs[code - WC_CURSH])(state, 0);
diff --git a/Src/signals.c b/Src/signals.c
index 4adf03202..2ce862490 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -672,9 +672,9 @@ zhandler(int sig)
 	    if ((isset(PRIVILEGED) || isset(RESTRICTED)) &&
 		isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL))
 		zexit(SIGINT, ZEXIT_SIGNAL);
+            errflag |= ERRFLAG_INT;
             if (list_pipe || chline || simple_pline) {
                 breaks = loops;
-                errflag |= ERRFLAG_INT;
 		inerrflush();
 		check_cursh_sig(SIGINT);
             }

  parent reply	other threads:[~2021-05-16 17:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16  9:16 Arseny Maslennikov
2021-05-16 14:28 ` Bart Schaefer
2021-05-16 15:46   ` Bart Schaefer
2021-05-16 16:15     ` Mikael Magnusson
2021-05-16 16:22       ` Lawrence Velázquez
2021-05-16 17:47       ` Bart Schaefer [this message]
2021-05-16 18:23         ` Martijn Dekker
2021-05-16 19:59           ` Bart Schaefer
2021-05-16 20:34             ` Peter Stephenson
2021-05-16 21:19               ` [PATCH] volatile declarations (was Re: 'while do done' hangs interactive zsh) Bart Schaefer
2021-05-16 23:40                 ` Martijn Dekker
2021-05-16 16:43 ` 'while do done' hangs interactive zsh Stephane Chazelas
2021-05-16 18:02   ` Bart Schaefer
2021-05-16 18:25     ` Martijn Dekker

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=7YOf2eWnB_0GO_ZhPSWP285Fz-YpBr7O7ZTfp+-XP=QLg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=ar@cs.msu.ru \
    --cc=zsh-workers@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).