* Re: Bug: using send-break at "select" prompt breaks a bit too much
@ 1999-08-02 14:31 Sven Wischnowsky
0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-08-02 14:31 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Bug: using send-break at "select" prompt breaks a bit too much
@ 1999-08-01 7:39 Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-08-01 7:39 UTC (permalink / raw)
To: zsh-workers
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.
Now try the same thing with "zsh -ic oops". It shouldn't matter much.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-08-02 14:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-02 14:31 Bug: using send-break at "select" prompt breaks a bit too much Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-08-01 7:39 Bart Schaefer
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).