Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Waiting for a process without using pid
- X-seq: zsh-users 15416
- From: PJ Weisberg <pj@xxxxxxxxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Waiting for a process without using pid
- Date: Mon, 20 Sep 2010 09:50:13 -0700
- Cc: zsh-users@xxxxxxx
- In-reply-to: <100920075521.ZM30584@xxxxxxxxxxxxxxxxxxxxxx>
- 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: <AANLkTinyDC-OoGBzuisMKUg+OqeeqG=HKZrNDuJZL+sD@xxxxxxxxxxxxxx> <100916072654.ZM29712@xxxxxxxxxxxxxxxxxxxxxx> <4C950347.9060109@xxxxxxxxx> <100918124147.ZM31152@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTimY1T1n9Nq7ePkNdSbJ9zhPobwzwM5SfNYb8qfB@xxxxxxxxxxxxxx> <100920075521.ZM30584@xxxxxxxxxxxxxxxxxxxxxx>
On Mon, Sep 20, 2010 at 7:55 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> Perhaps I was trying to make my solution too general; i.e., I didn't
> want to care how many children were started or whether their PIDs had
> been remembered. But if you always have exactly two children, why not
> this?
>
> coproc read -E
> trap "print -p" CHLD
>
> ./child.sh &
> pid1=$!
> ./child.sh &
> pid2=$!
>
> read -p
> kill $pid1 >&/dev/null
> kill $pid2 >&/dev/null
You *can* rewrite that to not care how many children there are.
for thing in $stuff; do
./child.sh $thing
set -A pids $pids $!
done
for child in $pids; do
kill $child >&/dev/null
done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author