Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
- X-seq: zsh-users 16628
- From: Jérémie Roquet <arkanosis@xxxxxxxxx>
- To: Rory Mulvaney <rorymulv@xxxxxxxxx>
- Subject: Re: wait for the next process to finish
- Date: Tue, 13 Dec 2011 17:45:37 +0100
- Cc: zsh-users@xxxxxxx, Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>, Anthony R Fletcher <arif@xxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ncbnogcVhii3D7F3GoR3hVYCv3SU2TucHE/t/EIjQ8k=; b=DfEccUVvGo5frF0jbhZLapjpWRcVoTq3XxPHs9pUu8uXugx/3ALlfCF0EW/78MWiuJ KsDVvgToJWiT4dJGNR5rik6MG/UXixXeP0+DsOF10pV6PH1vqyAohQYxmqGgQpoPyO07 HnIE8J8WSpXdKOYWgLv64mCuol3/7lHbbqEvE=
- In-reply-to: <alpine.DEB.2.00.1112130937120.13348@MyComp.localdomain>
- 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> <CAHSx_Sv8g+tQQnytijXd=HOSHkyu-vwcmjCaDWoHhp2ba+whHw@mail.gmail.com> <alpine.DEB.2.00.1112130937120.13348@MyComp.localdomain>
Hi,
2011/12/13 Rory Mulvaney <rorymulv@xxxxxxxxx>:
> To clarify (I think this is fairly simple), you can supply the process id
> as a parameter to 'wait', and though the $! method seems rather clumsy to
> retrieve the pid (since you have to retrieve it somehow in the next
> command after spawning the background process), it seems to work mostly in
> general.
>
> So you could do:
>
> sleep 20000 &
> sleep 20 &
> pid=$!
> wait $pid
>
> That will just wait for the sleep 20 process to complete while the sleep
> 20000 process still runs in the background.
Actually, it'll always wait for the last spawned job, not for the
first job to finish.
If you spawn them in the reverse order, ie:
sleep 20 &
sleep 20000 &
pid=$!
wait $pid
This will wait for the sleep 20000 process, even if the sleep 20 has
finished for long.
Best regards,
--
Jérémie
Messages sorted by:
Reverse Date,
Date,
Thread,
Author