From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Bug: using send-break at "select" prompt breaks a bit too much
Date: Mon, 2 Aug 1999 16:31:10 +0200 (MET DST) [thread overview]
Message-ID: <199908021431.QAA13865@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Sun, 1 Aug 1999 07:39:19 +0000
Bart Schaefer wrote:
> Check this out:
>
> function oops() {
> setopt localoptions localtraps
> trap "echo got signal" 0 1 2 3 15 ZERR DEBUG
> select x in a b c
> do echo $REPLY
> done
> echo "finished select"
> }
>
> Put that in your $fpath and run "oops". Try ^C and ^\ (or ^_ or whatever
> you have sending QUIT). Then use ^G (send-break). Note that the whole
> function is killed, but "finished select" is never printed nor are any
> traps triggered.
The patch below makes errflag be restored after the call to zleread()
so that only the select is left.
I don't get a trap for QUIT, either (and I haven't found the place
where this is inhibited), however, I get the traps for SIGINT and
DEBUG.
But while playing with this I found a more serious bug:
% TRAPQUIT() { echo quit }
% foo() { setopt localtraps; trap 'echo foo quit' 3 }
% foo
... and bang! dosavetrap() called shfunctab->removenode() which called
removeshfuncnode() which called dosavetrap again -- removing the list
for the trap we want to get at the first call to dosavetrap(). We
ended up with a savetrap struct with the ZSIG_FUNC flag and a NULL
list pointer which gave us a SEGV in endtrapscope().
Bye
Sven
diff -u os/loop.c Src/loop.c
--- os/loop.c Mon Aug 2 11:44:46 1999
+++ Src/loop.c Mon Aug 2 15:51:11 1999
@@ -178,8 +178,13 @@
for (;;) {
if (empty(bufstack)) {
if (interact && SHTTY != -1 && isset(USEZLE)) {
+ int oef = errflag;
+
isfirstln = 1;
str = (char *)zleread(prompt3, NULL, 0);
+ if (errflag)
+ str = NULL;
+ errflag = oef;
} else {
str = promptexpand(prompt3, 0, NULL, NULL);
zputs(str, stderr);
diff -u os/signals.c Src/signals.c
--- os/signals.c Mon Aug 2 11:44:47 1999
+++ Src/signals.c Mon Aug 2 16:22:38 1999
@@ -640,7 +640,11 @@
*/
char func[20];
sprintf(func, "TRAP%s", sigs[sig]);
- st->list = shfunctab->removenode(shfunctab, func);
+ /* We call removehashnode() directly because otherwise
+ * removeshfuncnode() would be called which in turn would
+ * call us again so that we would end up with a NULL pointer
+ * instead of the list for the trap. */
+ st->list = removehashnode(shfunctab, func);
} else {
st->list = sigfuncs[sig];
unsettrap(sig);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~1999-08-02 14:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-02 14:31 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-08-01 7:39 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=199908021431.QAA13865@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).