From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18983 invoked by alias); 13 Dec 2011 17:09:51 -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: 16630 Received: (qmail 26959 invoked from network); 13 Dec 2011 17:09:40 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at mail.nih.gov designates 128.231.90.100 as permitted sender) X-IronPortListener: NIH_Relay X-SBRS: None X-IronPort-AV: E=Sophos;i="4.71,346,1320642000"; d="scan'208";a="127464528" X-Authentication-Warning: cosy.cit.nih.gov: arif set sender to Anthony R Fletcher using -f Date: Tue, 13 Dec 2011 11:59:29 -0500 From: Anthony R Fletcher To: Subject: Re: wait for the next process to finish Message-ID: <20111213165929.GA10308@cosy.cit.nih.gov> 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.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (cake.cit.nih.gov [165.112.93.31]); Tue, 13 Dec 2011 11:59:29 -0500 (EST) > 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. Anthony. -- Anthony R Fletcher Room 2033, Building 12A, http://dcb.cit.nih.gov/~arif National Institutes of Health, arif@mail.nih.gov 12A South Drive, Bethesda, Phone: (+1) 301 402 1741. MD 20892-5624, USA.