From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6519 invoked from network); 15 Dec 2006 10:04:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO,HTML_40_50,HTML_MESSAGE autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Dec 2006 10:04:32 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 27941 invoked from network); 15 Dec 2006 10:04:26 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Dec 2006 10:04:26 -0000 Received: (qmail 1282 invoked by alias); 15 Dec 2006 10:04:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23053 Received: (qmail 1273 invoked from network); 15 Dec 2006 10:04:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Dec 2006 10:04:22 -0000 Received: (qmail 27625 invoked from network); 15 Dec 2006 10:04:22 -0000 Received: from eq2.spamarrest.com (66.150.163.135) by a.mx.sunsite.dk with SMTP; 15 Dec 2006 10:04:15 -0000 Received: from [192.168.1.2] (ppp-68-122-225-12.dsl.pltn13.pacbell.net [68.122.225.12]) by eq2.spamarrest.com (Postfix) with ESMTP id 0FA8960C1B3 for ; Fri, 15 Dec 2006 02:04:11 -0800 (PST) Mime-Version: 1.0 Message-Id: Date: Fri, 15 Dec 2006 02:04:04 -0800 To: zsh-workers@sunsite.dk From: Dave Yost Subject: Is wait not interruptable? Content-Type: multipart/alternative; boundary="============_-1045945444==_ma============" --============_-1045945444==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" Hi. This program isn't working as I would expect: #!/bin/zsh (sleep 3 ; echo A) & proc1=$! (sleep 4 ; echo B) & proc2=$! trap 'echo kill $proc2 $proc1 ; kill $proc2 $proc1' INT wait $proc1 kill $proc2 #ps Here's what it does: 315 Z% wait-kill-test A 316 Z% wait-kill-test ^Ckill 4099 4098 317 Z% echo $ZSH_VERSION 4.2.3 318 Z% uname -a Darwin ip2 8.8.2 Darwin Kernel Version 8.8.2: Thu Sep 28 20:43:26 PDT 2006; root:xnu-792.14.14.obj~1/RELEASE_I386 i386 i386 319 Z% In the second run, the ^C was typed 1 second after the command was started, and the first sleep plodded along to completion for its full 3 seconds. Why wasn't the first sleep killed by the kill command in the trap? This is on Mac OS X 10.4.8. When I run this code with Bash 2.05b.0(1)-release, the ^C does cause the first sleep to be killed instantly. I need this to work correctly for an enhancement to http://Yost.com/computers/d That will allow you to say that you want to tail -f the output until the backgrounded completes or until you type ^C. Thanks Dave --============_-1045945444==_ma============ Content-Type: text/html; charset="us-ascii" Is wait not interruptable?
Hi.
This program isn't working as I would expect:

#!/bin/zsh

(sleep 3 ; echo A) &
proc1=$!
(sleep 4 ; echo B) &
proc2=$!
trap 'echo kill $proc2 $proc1 ; kill $proc2 $proc1' INT
wait $proc1
kill $proc2
#ps

Here's what it does:

315 Z% wait-kill-test
A
316 Z% wait-kill-test
^Ckill 4099 4098
317 Z% echo $ZSH_VERSION
4.2.3
318 Z% uname -a
Darwin ip2 8.8.2 Darwin Kernel Version 8.8.2: Thu Sep 28 20:43:26 PDT 2006; root:xnu-792.14.14.obj~1/RELEASE_I386 i386 i386
319 Z%

In the second run, the ^C was typed 1 second after the command was started, and the first sleep plodded along to completion for its full 3 seconds.  Why wasn't the first sleep killed by the kill command in the trap?  This is on Mac OS X 10.4.8.

When I run this code with Bash 2.05b.0(1)-release, the ^C does cause the first sleep to be killed instantly.

I need this to work correctly for an enhancement to
  http://Yost.com/computers/d
That will allow you to say that you want to tail -f the output until the backgrounded completes or until you type ^C.

Thanks

Dave
--============_-1045945444==_ma============--