From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14257 invoked from network); 18 Jul 2009 10:32:25 -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 10:32:25 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 24443 invoked from network); 18 Jul 2009 10:23:31 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Jul 2009 10:23:31 -0000 Received: (qmail 17587 invoked by alias); 18 Jul 2009 10:23:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27158 Received: (qmail 17563 invoked from network); 18 Jul 2009 10:23:14 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 Jul 2009 10:23:14 -0000 Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5]) by bifrost.dotsrc.org (Postfix) with ESMTP id 86070801E289 for ; Sat, 18 Jul 2009 12:23:09 +0200 (CEST) Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id 0C5C2D48152; Sat, 18 Jul 2009 12:23:06 +0200 (CEST) Received: from xvii.vinc17.org (c5850-a2-3-62-147-11-200.dial.proxad.net [62.147.11.200]) by smtp5-g21.free.fr (Postfix) with ESMTP id C0EF6D48092; Sat, 18 Jul 2009 12:23:02 +0200 (CEST) Received: from vinc17 by xvii.vinc17.org with local (Exim 4.69) (envelope-from ) id 1MS6xW-0004A3-5k; Sat, 18 Jul 2009 12:16:02 +0200 Date: Sat, 18 Jul 2009 12:16:02 +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: <20090718101602.GA5392@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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <090717222936.ZM8648@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-17 22:29:36 -0700, Bart Schaefer wrote: > When running a shell script (not interactively), zsh does NO HANDLING > of SIGINT whatsoever. It's implementing IUE, not WUE. Or to be more > precise, it's implementing the default behavior on SIGINT, which is > usually to exit. Yes, this is what I can see with zsh 4.3.10 (but zsh 4.2.3 implemented WUE). > 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. Anyway, even though bash implements WCE, 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). For instance, you can try with the following script with both bash and zsh: ------------------------------------------------------------ echo "Caller: $$" cmd="echo \"Callee: \$\$ ($SHELL)\"; sleep 6; echo OK" trp="trap 'echo SIGINT; exit' INT; $cmd" echo "Send SIGINT to each callee's PID" $SHELL -c "$cmd"; echo "Callee's exit status: $?" $SHELL -c "$trp"; echo "Callee's exit status: $?" trap '' INT echo "SIGINT ignored" $SHELL -c "$cmd"; echo "Callee's exit status: $?" $SHELL -c "$trp"; echo "Callee's exit status: $?" trap 'echo "Caller received SIGINT"' INT echo "Type Ctrl-C in the terminal" $SHELL -c "$cmd"; echo "Callee's exit status: $?" $SHELL -c "$trp"; echo "Callee's exit status: $?" ------------------------------------------------------------ Try also "killall -INT sleep" in the 6 cases. > 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. If the caller ignores SIGINT, then bash also ignores it. Moreover bash terminates with exit status 130 only when it receives SIGINT and the child terminates with exit status 130. (I've tried on a Linux machine with bash 3.2 because I don't have access to my Mac OS X machine right now.) > Having said all that, I also looked at what it would take to implement > WCE as an option. There are two complications here: > > (1) There's a race condition as to whether the shell receives SIGINT > or SIGCHLD first. With enough trials I can get it to happen either > way, though the vast majority of the time the SIGINT wins. How does bash handle that? BTW, I wonder why typing Ctrl-g in emacs sends SIGINT to the parent under Mac OS X, but not under Linux. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)