Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
- X-seq: zsh-users 16629
- From: "Christoph (Stucki) von Stuckrad" <stucki@xxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: wait for the next process to finish
- Date: Tue, 13 Dec 2011 17:49:56 +0100
- 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>
- Mail-followup-to: zsh-users@xxxxxxx
- 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>
- Sender: "Chr. von Stuckrad" <stucki@xxxxxxxxxxxxxxx>
On Tue, 13 Dec 2011, Rory Mulvaney wrote:
> > 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() {
...
> > }
...
> > It might be nice to set an environment parameter with the pid and status
> > info right before the dotrap(SIGCHLD) call in jobs.c.
...
This sounds very promising, because you then could 'parallelize'
a loop by feeding it new processes when 'one of the runnig' dies.
I hope for something in the line of:
TRAPCHILD() { ... ... ... }
pids=( )
for i in some paramters given
do
if [[ $#pids >= $MAXPARALLEL ]]
then sleep 1 # and TRAPCHILD will remove 'done's
else
call $i &
pids+=$!
fi
done
SO one might be able to keep a bunch of CPUS working
for 'one given loop' without needing to know which
case is done first? (And only if the parallelities
do not break something like tempfiles, stderr, etc ...)
Stucki
--
Christoph von Stuckrad * * |nickname |Mail <stucki@xxxxxxxxxxxxxxx> \
Freie Universitaet Berlin |/_*|'stucki' |Tel(Mo.,Mi.):+49 30 838-75 459|
Mathematik & Informatik EDV |\ *|if online| (Di,Do,Fr):+49 30 77 39 6600|
Takustr. 9 / 14195 Berlin * * |on IRCnet|Fax(home): +49 30 77 39 6601/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author