From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2776 invoked from network); 3 Aug 2008 11:27:35 -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=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Aug 2008 11:27:35 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 54847 invoked from network); 3 Aug 2008 11:27:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Aug 2008 11:27:25 -0000 Received: (qmail 24863 invoked by alias); 3 Aug 2008 11:27:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25378 Received: (qmail 24843 invoked from network); 3 Aug 2008 11:27:14 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Aug 2008 11:27:14 -0000 Received: from mtaout01-winn.ispmail.ntl.com (mtaout01-winn.ispmail.ntl.com [81.103.221.47]) by bifrost.dotsrc.org (Postfix) with ESMTP id 4E62580590E6 for ; Sun, 3 Aug 2008 13:27:11 +0200 (CEST) Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20080803112711.NGBC777.mtaout01-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Sun, 3 Aug 2008 12:27:11 +0100 Received: from pws-pc ([81.107.40.67]) by aamtaout04-winn.ispmail.ntl.com with ESMTP id <20080803112711.GQGM18637.aamtaout04-winn.ispmail.ntl.com@pws-pc> for ; Sun, 3 Aug 2008 12:27:11 +0100 Date: Sun, 3 Aug 2008 12:27:08 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: Problems with background jobs in a script. Message-ID: <20080803122708.3be66cdb@pws-pc> In-Reply-To: References: X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.11; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/7920/Sun Aug 3 10:44:32 2008 on bifrost X-Virus-Status: Clean On Fri, 1 Aug 2008 05:18:16 -0700 Dave Yost wrote: > The script below exhibits several problems. > > All I'm trying to do is to get a script to recursively kill all of > its background processes on exit. (In my case, this should be an > issue only when the script is killed.) I'm actually suprised it gets as far as it does. Essentially no thought has been put into to job control for non-interactive shells (when the MONITOR option is not set); it so happens zsh still uses its job table for storing information about jobs it's started, but many of the fixes to make things appear seamless (or at least more closely stitched) only work with MONITOR. That may be fixable to some extent (particularly with background jobs where the task is already separate from the main shell even without the normal job control OS support) but there's so much to do to the shell I shouldn't hold your breath. You could try pretending the script is interactive (with the -i option --- I tried this it and certainly made a better stab at your script) but that may have side effects. Possibly it's simpler to keep track of the process numbers you need to kill by recording them from $!. However, since in this case the shell doesn't guarantee to tell you when the process is terminated you can't be absolutely sure you're killing the right process. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/