Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
- X-seq: zsh-users 16623
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: wait for the next process to finish
- Date: Mon, 12 Dec 2011 11:41:30 -0800
- 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=
- In-reply-to: <20111212154601.GA5198@cosy.cit.nih.gov>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20111212154601.GA5198@cosy.cit.nih.gov>
- Sender: 4wayned@xxxxxxxxx
On Mon, Dec 12, 2011 at 7:46 AM, Anthony R Fletcher <arif@xxxxxxxxxxxx>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..
Messages sorted by:
Reverse Date,
Date,
Thread,
Author