Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: wait for the next process to finish
On Dec 13, 5:49pm, Christoph (Stucki) von Stuckrad wrote:
}
} This sounds very promising, because you then could 'parallelize'
} a loop by feeding it new processes when 'one of the runnig' dies.
That much you can do already.
TRAPCHLD() {
while (( ${#jobstates} < MAXPARALLEL ))
do the background task &
done
}
(Of course you need some sort of other loop-ending condition, but you
get the idea.)
You don't really even need the trap for this, your original loop will
work fine as long as you examine ${(k)jobstates} as the list of PIDs
instead of trying to maintain your own array.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author