From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8588 invoked by alias); 13 Dec 2011 16:50:47 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16629 Received: (qmail 4718 invoked from network); 13 Dec 2011 16:50:44 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at mi.fu-berlin.de does not designate permitted sender hosts) Date: Tue, 13 Dec 2011 17:49:56 +0100 From: "Christoph (Stucki) von Stuckrad" To: zsh-users@zsh.org Subject: Re: wait for the next process to finish Message-ID: <20111213164906.GH20573@localhost.mi.fu-berlin.de> Mail-Followup-To: zsh-users@zsh.org References: <20111212154601.GA5198@cosy.cit.nih.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Sender: "Chr. von Stuckrad" X-Remote-IP: 160.45.113.41 X-Spam_Score: -5.2 X-exim-Spam_Score_Int: -51 X-exim-Spam_Bar: ----- X-Spam_Report: * -1.0 ALL_TRUSTED Nachricht wurde nur ueber vertrauenswuerdige Rechner * weitergeleitet * -2.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain * -1.9 BAYES_00 BODY: Spamwahrscheinlichkeit nach Bayes-Test: 0-1% * [score: 0.0000] X-Originating-IP: 160.45.117.149 On Tue, 13 Dec 2011, Rory Mulvaney wrote: > > On Mon, Dec 12, 2011 at 7:46 AM, Anthony R Fletcher 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 \ 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/