From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26411 invoked by alias); 13 Dec 2011 18:16:35 -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: 16637 Received: (qmail 2898 invoked from network); 13 Dec 2011 18:16:23 -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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) 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= X-Sasl-enc: m7Nf0WXrp+lbruE936rw4neruZSEsTKV7P+UMqjQJ3Xw5QqIvYeVZSHnpzKtuQ 1323799708 Date: Tue, 13 Dec 2011 20:08:11 +0200 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: wait for the next process to finish Message-ID: <20111213175659.GA16637@daniel3.local> References: <20111212154601.GA5198@cosy.cit.nih.gov> <20111213165929.GA10308@cosy.cit.nih.gov> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111213165929.GA10308@cosy.cit.nih.gov> User-Agent: Mutt/1.5.20 (2009-06-14) Anthony R Fletcher wrote on Tue, Dec 13, 2011 at 11:59:29 -0500: > > 2011/12/13 Rory Mulvaney : > > > 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?