From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4512 invoked from network); 11 Sep 2001 14:36:44 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 11 Sep 2001 14:36:44 -0000 Received: (qmail 4570 invoked by alias); 11 Sep 2001 14:36:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15788 Received: (qmail 4547 invoked from network); 11 Sep 2001 14:36:30 -0000 From: Bart Schaefer Message-Id: <1010911143626.ZM24553@candle.brasslantern.com> Date: Tue, 11 Sep 2001 14:36:26 +0000 In-Reply-To: <200109101450.KAA75715@raptor.research.att.com> Comments: In reply to David Korn "Re: Value of $? after signal" (Sep 10, 10:50am) References: <200109101450.KAA75715@raptor.research.att.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: Value of $? after signal MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 10, 10:50am, David Korn wrote: } [Bart wrote:] } > [I just sent a very similar message to the zsh-workers list.] } > } > The return value of a simple command is its exit status, } > or 128+n if the command is terminated by signal n. } > } > What does ksh do? } } First of all, ksh uses } 256+signo } for processes that terminate due to a signal. Otherwise, there } is no way to distinguish between a process that does exit(130) } and one that terminated due to a SIGINT. I was looking at this a bit more. There are a couple of places in exec.c and jobs.c where zsh tests (the equivalent of) `lastval & 0200' to decide whether a child process got a signal. That means a child that explicitly calls exit(130) can fool zsh into interrupting a loop (jobs.c:338) or (I think) "propagating" a signal to the entire process group (exec.c:1070). To see the jobs.c problem, compare: yes | for x in a b c; do echo $x; (exit 2); echo $?; done yes | for x in a b c; do echo $x; (exit 130); echo $?; done I haven't come up with an example for the exec.c issue, but it should be something similar to the above (requires a loop on the right of a pipe). -- 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