From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8237 invoked from network); 17 Feb 2006 18:08:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Feb 2006 18:08:25 -0000 Received: (qmail 15472 invoked from network); 17 Feb 2006 18:08:19 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Feb 2006 18:08:19 -0000 Received: (qmail 377 invoked by alias); 17 Feb 2006 18:08:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22277 Received: (qmail 368 invoked from network); 17 Feb 2006 18:08:15 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Feb 2006 18:08:15 -0000 Received: (qmail 15232 invoked from network); 17 Feb 2006 18:08:15 -0000 Received: from dan.emsphone.com (199.67.51.101) by a.mx.sunsite.dk with SMTP; 17 Feb 2006 18:08:13 -0000 Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.4) id k1HI8AYl076147 for zsh-workers@sunsite.dk; Fri, 17 Feb 2006 12:08:10 -0600 (CST) (envelope-from dan) Date: Fri, 17 Feb 2006 12:08:10 -0600 From: Dan Nelson To: zsh-workers@sunsite.dk Subject: Re: [4.2/4.3] Bug with wait and trapped signals Message-ID: <20060217180810.GD52817@dan.emsphone.com> References: <20060217142816.GE1708@prunille.vinc17.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vtzGhvizbBRQ85DL" Content-Disposition: inline In-Reply-To: <20060217142816.GE1708@prunille.vinc17.org> X-OS: FreeBSD 5.4-STABLE X-message-flag: Outlook Error User-Agent: Mutt/1.5.11 --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In the last episode (Feb 17), Vincent Lefevre said: > zsh (all versions?) does not interrupt a "wait" when it receives a > signal for which a trap has been set. > > For instance, consider the following script: > > #!/usr/bin/env zsh > echo "PID = $$" > sleep 60 & > trap 'echo term; exit 0' TERM > wait Here's the test I've been using. All shells I've tested except zsh and FreeBSD's ash interrupt the wait, but only bash returns the correct value from wait #1. I tested Solaris 10 /bin/sh and /bin/ksh, FreeBSD 5's /bin/sh, zsh-4.2.6 and ksh93-20060124 ports, and Debian's bash-2.05b-14 and ash-0.5.2-5. -- Dan Nelson dnelson@allantgroup.com --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=waittest #! /bin/sh # SIG=15 echo "\ Correct order is: parent waiting on \$childpid child sending signal to \$parentpid parent received signal wait #1 finished, gotsig=1, status=a number > 128, possibly $(($SIG+128)) child exiting wait #2 finished, gotsig=0, status=33 " gotsig=0 signal_handler() { echo "parent received signal" gotsig=1 } child() { sleep 2 echo "child sending signal to pid $parentpid" kill -$SIG $parentpid sleep 2 echo "child exiting" exit 33 } parentpid=$$ echo "parent's pid is $parentpid" child & childpid=$! trap signal_handler $SIG echo "parent waiting on pid $childpid" wait $childpid cstatus=$? echo "wait #1 finished, gotsig=$gotsig, status=$cstatus" gotsig=0 wait $childpid cstatus=$? echo "wait #2 finished, gotsig=$gotsig, status=$cstatus" --vtzGhvizbBRQ85DL--