Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Is wait not interruptable?



Title: 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


Messages sorted by: Reverse Date, Date, Thread, Author