Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
- X-seq: zsh-users 16637
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: wait for the next process to finish
- Date: Tue, 13 Dec 2011 20:08:11 +0200
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=mesmtp; bh=ELFD6T4HeZZ 5aMiz3p52t1ELFdY=; b=PHe7gXRRnOYYS4DrQtk7uYNr23i4SCFHap9lDCyVrPW 89pGcplNLxubtoj0D0JhKw0kmlSLs58pEVdhpGFzjc+he1W6IjEoeoQVw7bSusxv U1UysBIWU0Jw0oLxL4ift1wC3D1XyffhKgx6MPIq1UaWV731TNOLZ5TfEhHQ5ong =
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :references:mime-version:content-type:in-reply-to; s=smtpout; bh=ELFD6T4HeZZ5aMiz3p52t1ELFdY=; b=oX8J+X9url6Ec4sLmMEzwk/BxRVN xEwv/AE28yJTLQd9WAHzEJAROFVhpmzh4gopu+fr1cFzY+PwllTPwl+v+qq+Gm5q SemZQdwyzh/yYAnaKwHTugWuoXNWZo8OSgiRR5gjaQg6JzquZcNO0lX1CvX/PJWr D9jucl+elmYT01Q=
- In-reply-to: <20111213165929.GA10308@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> <CAHSx_Sv8g+tQQnytijXd=HOSHkyu-vwcmjCaDWoHhp2ba+whHw@mail.gmail.com> <alpine.DEB.2.00.1112130937120.13348@MyComp.localdomain> <CAFOazAN9KMUHaUZCMj7usd_m6NwGERdRZ-9Mc+-oP8jbtbsHOg@mail.gmail.com> <20111213165929.GA10308@cosy.cit.nih.gov>
Anthony R Fletcher wrote on Tue, Dec 13, 2011 at 11:59:29 -0500:
> > 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.
>
> Yes, the need to to wait for any of the processes to end so I can start
> another. Basically a poor man's batch system.
'xargs -P' and 'make -j' were already suggested upthread; is the task
you're trying to parallelize not suitable for those approaches?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author