zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: 'while do done' hangs interactive zsh
Date: Sun, 16 May 2021 12:59:11 -0700	[thread overview]
Message-ID: <CAH+w=7a0TgRv6suqoJob7wdhA-vNL5xB3ocVR2Em2=MGHaGFqw@mail.gmail.com> (raw)
In-Reply-To: <97227908-8f84-65b6-a3b0-81c5e16d91d9@inlv.org>

On Sun, May 16, 2021 at 11:25 AM Martijn Dekker <martijn@inlv.org> wrote:
>
> Op 16-05-21 om 19:47 schreef Bart Schaefer:
> > Let's try the attached, then?
>
> Interactive zsh with that patch still locks up on 'while do done'

So this is MacOS:

% TRAPINT() { print Got INT }
% while do done
^CGot INT
^CGot INT
^CGot INT
^CGot INT
^CGot INT

That's exactly what also happens on Ubuntu.  But if I change that to:

% TRAPINT() { print Got INT; break }

Then on Ubuntu a ^C stops the loop, but on MacOS it does not.  This
implies that the value of the global "breaks" is not propagating into
execwhile() when set from the signal handler.  This may be an
optimization problem with clang?   Some random fiddling indicates that
the value of "errflag" may not be propagating out of the signal
handler either.

Indeed, this seems to fix it for MacOS:

diff --git a/Src/loop.c b/Src/loop.c
index aa733a2cb..db5b3e097 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -43,7 +43,7 @@ mod_export int contflag;
 /* # of break levels */

 /**/
-mod_export int breaks;
+mod_export volatile int breaks;

 /**/
 int

Do we need to worry about compilers that don't accept "volatile"?  I'd
suggest throwing "volatile" into the computed definition of
"mod_export" except I've forgotten whether there is such a thing as
declaring a function to be volatile.


  reply	other threads:[~2021-05-16 19:59 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
2021-05-16 18:23         ` Martijn Dekker
2021-05-16 19:59           ` Bart Schaefer [this message]
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=7a0TgRv6suqoJob7wdhA-vNL5xB3ocVR2Em2=MGHaGFqw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --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).