From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3007 invoked from network); 26 Apr 2005 22:15:14 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 26 Apr 2005 22:15:14 -0000 Received: (qmail 52105 invoked from network); 26 Apr 2005 22:15:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Apr 2005 22:15:03 -0000 Received: (qmail 21796 invoked by alias); 26 Apr 2005 22:14:55 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8760 Received: (qmail 21782 invoked from network); 26 Apr 2005 22:14:54 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 26 Apr 2005 22:14:54 -0000 Received: (qmail 50858 invoked from network); 26 Apr 2005 22:14:54 -0000 Received: from lakermmtao12.cox.net (68.230.240.27) by a.mx.sunsite.dk with SMTP; 26 Apr 2005 22:14:47 -0000 Received: from quark.hightek.org ([68.12.75.33]) by lakermmtao12.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050426221445.UTYV10612.lakermmtao12.cox.net@quark.hightek.org> for ; Tue, 26 Apr 2005 18:14:45 -0400 Received: by quark.hightek.org (Postfix, from userid 501) id 7D1D445898; Tue, 26 Apr 2005 17:12:47 -0500 (CDT) Date: Tue, 26 Apr 2005 17:12:47 -0500 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: Re: localtraps Message-ID: <20050426221247.GA3964@quark.hightek.org> References: <20050425063521.GA17598@quark.hightek.org> <1050425163202.ZM25027@candle.brasslantern.com> <20050426030308.GA21501@quark.hightek.org> <200504261834.j3QIYHSa018951@news01.csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200504261834.j3QIYHSa018951@news01.csr.com> User-Agent: Mutt/1.4.1i X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Tue, Apr 26, 2005 at 07:34:16PM +0100, Peter Stephenson wrote: > Vincent Stemen wrote: > > I had hoped that I could get around the problem for now by explicitly > > resetting the signal trap without using localtraps but, as you > > indicated, it will not let me do anything with the same signal while > > it is in the signal handler function. This is a real problem that I > > don't know how to get around. > > The problem may be related to the fact that the shell executes traps > from within the signal handler. Other shells presumably wait for the > handler to exit and execute the trap at the next obvious point (e.g. a > command executed). I am not sure if this is exactly what you are saying, but zsh on NetBSD queues the next signal and will not re-call the signal handler until it exits the handler from the first one. However, I can trap a different signal from within the signal handler and if it catches that new signal, it immediatly re-calls the handler. It just won't do it on the same signal. One thing I tried was to set a flag indicating that the signal had already hit once so that when it re-calls the sig handler it would know it was the second time. That did not work though for the same reason. I cannot reset the flag before exiting the function because it always completes the function before processing the next signal and re-calling it. So on the next signal, the flag is always back unset. > However, I've tried this in some recent versions of zsh (4.2.0 and > 4.3.0-dev-1, which is a moving target) and it seems to do what I think > you want... abort the programme when you hit ^C twice quickly, otherwise > continue. So I'm not sure what you're doing wrong. My need generally is not just to require two ^C's to exit. I often need to print a message, have a delay, and/or do other work on the first signal and abort on the second one, or disable the signal all together while in the handler to perform some function so that another hit will not re-call the function, and then re-enable the signal just before exiting the handler. I also have written scripts before where I required more than two ^C's to abort in critical sections of code. Either way, I really need to be able to use the trap command on the same signal in the handler like I can in the BSD shell. It would also be very convenient to be able to use localtraps so that I don't have to explicitly reset the signal before returning. -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! Read how Network Solutions (NSI) was involved in stealing our domain name. http://www.InetAddresses.net