From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26265 invoked by alias); 12 Dec 2011 19:41:42 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16623 Received: (qmail 9994 invoked from network); 12 Dec 2011 19:41:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, HTML_MESSAGE,RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.41 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=3shEECKuz7NQNENVydbV6mF33hsrbSTddvRebPynxPA=; b=AOxihJhMorP48SSKplc/4antZWjIozIxBrQhzFoXIKv7Dut6gHaMlKxtGWQN8hLKRy nSf1FhxikzPe3gJbc8k2aGN9IChFuDr008DCupcUhRfEJlmLoyb5QANCREws6AJy64Rt 0SuijfgOuFfgmo4LV2UFs4GB0wZM1HsUCyPzA= MIME-Version: 1.0 Sender: 4wayned@gmail.com In-Reply-To: <20111212154601.GA5198@cosy.cit.nih.gov> References: <20111212154601.GA5198@cosy.cit.nih.gov> Date: Mon, 12 Dec 2011 11:41:30 -0800 X-Google-Sender-Auth: l7BeTo6-UxawKrZPMgLtKfAz3Ik Message-ID: Subject: Re: wait for the next process to finish From: Wayne Davison To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=0016e6dd8da53cb1bf04b3ea5219 --0016e6dd8da53cb1bf04b3ea5219 Content-Type: text/plain; charset=UTF-8 On Mon, Dec 12, 2011 at 7:46 AM, Anthony R Fletcher wrote: > How can I wait for just the next job to finish? > One thing that may help you is TRAPCHLD. Sadly, the signal handler doesn't tell you what pid it is reacting to, nor the exit code. TRAPCHLD() { echo here oldpids=($pids) pids=( ) for p in $oldpids; do if kill -0 $p 2>/dev/null; then pids+=$p else #wait $p # Sadly, this doesn't work echo $p exited fi done } pids=( ) sleep 10 & pids+=$! sleep 20 & pids+=$! (sleep 15; false) & pids+=$! echo $pids wait echo done It might be nice to set an environment parameter with the pid and status info right before the dotrap(SIGCHLD) call in jobs.c. ..wayne.. --0016e6dd8da53cb1bf04b3ea5219--