Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Allowing traps
- X-seq: zsh-workers 13176
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>, zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: PATCH: Re: Allowing traps
- Date: Mon, 20 Nov 2000 17:39:10 +0000
- In-reply-to: <0G4C000ND1N3ZY@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <0G4C000ND1N3ZY@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
On Nov 20, 4:54pm, Peter Stephenson wrote:
} Subject: Re: Allowing traps
}
} Bart wrote:
} > We don't need a flag ... the behavior should be that for all xxx, SIGxxx is
} > blocked when running the trap for that signal.
}
} That doesn't fix the problem that the shell will try and run traps already
} in the queue from within shell code called from the trap handler
Ahh, I see. Yes, that is a problem.
} I don't see a way of stopping that without a flag.
It looks to me like there's already a bad feedback loop between dotrap()
and doqueuedtraps().
doqueuedtraps() --> dotrap(sig, -1) --> RUNTRAPS() --> doqueuedtraps()
That's going to cause the queue to be unwound as a stack, isn't it? What
am I missing?
The patch below should fix both of those problems, I think.
There's still one more problem, which is that it might be possible for a
trap to get queued while it's not ignored, but then become ignored before
the queue runs. I think any trap that makes it into the queue ought to
get executed, regardless of whether it's ignored at the time the queue is
processed. We could probably fix this by inserting a call to RUNTRAPS()
in unsettrap().
I'm still a bit concerned that there's going to be a bad interaction between
queued signals and queued traps. Isn't there some way we could use the
signal queuing mechanism to deal with the trap issue, so that there's only
one queue?
Index: Src/signals.c
===================================================================
@@ -1010,12 +1010,12 @@
{
int sig, ota = trapsallowed;
- trapsallowed = 1;
+ trapsallowed = 0;
while (trapqused) {
trapqused--;
sig = *trapqueue;
memcpy(trapqueue, trapqueue + 1, trapqused * sizeof(int));
- dotrap(sig, -1);
+ dotrap(sig, 1);
}
trapsallowed = ota;
}
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author