From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11354 invoked from network); 18 Jul 2009 23:14:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 18 Jul 2009 23:14:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 33893 invoked from network); 18 Jul 2009 23:14:44 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Jul 2009 23:14:44 -0000 Received: (qmail 4441 invoked by alias); 18 Jul 2009 23:14:31 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27162 Received: (qmail 4427 invoked from network); 18 Jul 2009 23:14:30 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 Jul 2009 23:14:30 -0000 Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [212.27.42.4]) by bifrost.dotsrc.org (Postfix) with ESMTP id 9E257801E289 for ; Sun, 19 Jul 2009 01:14:25 +0200 (CEST) Received: from smtp4-g21.free.fr (localhost [127.0.0.1]) by smtp4-g21.free.fr (Postfix) with ESMTP id A9CE34C8085; Sun, 19 Jul 2009 01:14:23 +0200 (CEST) Received: from xvii.vinc17.org (c5850-a2-3-62-147-8-48.dial.proxad.net [62.147.8.48]) by smtp4-g21.free.fr (Postfix) with ESMTP id 36E844C805F; Sun, 19 Jul 2009 01:14:19 +0200 (CEST) Received: from vinc17 by xvii.vinc17.org with local (Exim 4.69) (envelope-from ) id 1MSJ22-0002cd-JN; Sun, 19 Jul 2009 01:09:30 +0200 Date: Sun, 19 Jul 2009 01:09:30 +0200 From: Vincent Lefevre To: zsh-workers@sunsite.dk Subject: Re: zsh 4.3.10 terminates with SIGINT when one types Ctrl-G in emacs under Mac OS X Message-ID: <20090718230930.GB5412@xvii> Mail-Followup-To: zsh-workers@sunsite.dk References: <090712193623.ZM14823@torch.brasslantern.com> <200907131839.n6DIdO6Z003291@pws-pc.ntlworld.com> <20090716162419.GA26179@prunille.vinc17.org> <090717222936.ZM8648@torch.brasslantern.com> <20090718101602.GA5392@xvii> <090718113509.ZM10405@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <090718113509.ZM10405@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.20-5983-vl-r30292 (2009-07-14) X-Virus-Scanned: ClamAV 0.94.2/9588/Sat Jul 18 07:14:41 2009 on bifrost X-Virus-Status: Clean On 2009-07-18 11:35:09 -0700, Bart Schaefer wrote: > On Jul 18, 12:16pm, Vincent Lefevre wrote: > } On 2009-07-17 22:29:36 -0700, Bart Schaefer wrote: > } > The point I believe Cracauer is overlooking is that the CALLER of the > } > shell script may have specified that SIGINT is to be ignored. SIG_IGN > } > is supposed to be inherited by child processes; but to implement WUE > } > or WCE, the shell must itself either ignore or handle SIGINT, which > } > may contradict what the caller has requested. > } > } I don't think that the caller should enforce what its children should > } do. Many programs will set their own SIGINT handler, even if the caller > } chose to ignore this signal. > > You've missed the point. SIG_IGN is by definition been inherited from > parent to child, and this is deliberately preserved across exec. The > parent doesn't *enforce* this -- the child is *allowed* to set up a > handler of its own once it gets control -- but the mere fact that the > execv'd program is a shell should not void the inherited signal settings. > The shell might merely be an intermediary that's going to exec itself > out of existence, and the programmer of the parent should be able to > expect that the inherited signal settings make it through. I didn't miss anything: the shell can still restore the previous status before an exec. > } Anyway, even though bash implements WCE, > > Except that bash *DOESN'T* implement WCE, at least not the way that it > is defined in Cracauer's web page. See below. According to my tests, bash *does* implement WCE. See below. > } it ignores SIGINT if the caller chose to ignore it; also when executing > } a process, it restores the trap to the default behavior, in case it was > } ignored (that's another difference with zsh). > > And that's a case where I think the zsh behavior is in fact preferable. Is there any reason? > } > Further I think Cracauer is very wrong here: > } > > } > Do nothing special when SIGINT appears while you wait for a child. You > } > don't even have to remember that one happened. > } > ... > } > Look at WIFSIGNALED(status) and WTERMSIG(status) to tell whether the > } > child says "I exited on SIGINT: in my opinion the user wants the > } > shellscript to be discontinued". > } > > } > This is plain nonsense. > } > > } > Not only does this potentially contradict a caller's explicit request > } > to ignore SIGINT, but the script should not exit 130 every time any > } > child exits 130. It should exit only when SIGINT was received *by the > } > script*. "kill -INT ..." of the child should not cause the shell to > } > behave as if it was interrupted. Try it with bash. > } > } It seems that bash behaves correctly in all those cases. > > Exactly -- which it would not if it followed Cracauer's advice; he's > wrong, and I'm not going to advocate that zsh adopt the behavior that > he describes. Well, after re-reading, I agree Cracauer's advice is wrong here. But it is fixable and I think that the other parts of his page are correct. At least, IUE/WUE/WCE are defined under the context "There are several ways to handle abortion of shell scripts when SIGINT is received while a foreground child runs", so it is clear that the shell *must* receive a SIGINT (this is also said near the beginning of the page). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)