From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14223 invoked from network); 20 Nov 2000 17:40:14 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 20 Nov 2000 17:40:14 -0000 Received: (qmail 22462 invoked by alias); 20 Nov 2000 17:40:06 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13176 Received: (qmail 22445 invoked from network); 20 Nov 2000 17:40:04 -0000 From: "Bart Schaefer" Message-Id: <1001120173911.ZM10192@candle.brasslantern.com> Date: Mon, 20 Nov 2000 17:39:10 +0000 In-Reply-To: <0G4C000ND1N3ZY@la-la.cambridgesiliconradio.com> Comments: In reply to Peter Stephenson "Re: Allowing traps" (Nov 20, 4:54pm) References: <0G4C000ND1N3ZY@la-la.cambridgesiliconradio.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Peter Stephenson , zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: Re: Allowing traps MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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