From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11065 invoked by alias); 13 Dec 2011 16:46:13 -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: 16628 Received: (qmail 12788 invoked from network); 13 Dec 2011 16:46:01 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.83.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=ncbnogcVhii3D7F3GoR3hVYCv3SU2TucHE/t/EIjQ8k=; b=DfEccUVvGo5frF0jbhZLapjpWRcVoTq3XxPHs9pUu8uXugx/3ALlfCF0EW/78MWiuJ KsDVvgToJWiT4dJGNR5rik6MG/UXixXeP0+DsOF10pV6PH1vqyAohQYxmqGgQpoPyO07 HnIE8J8WSpXdKOYWgLv64mCuol3/7lHbbqEvE= MIME-Version: 1.0 In-Reply-To: References: <20111212154601.GA5198@cosy.cit.nih.gov> From: =?UTF-8?B?SsOpcsOpbWllIFJvcXVldA==?= Date: Tue, 13 Dec 2011 17:45:37 +0100 Message-ID: Subject: Re: wait for the next process to finish To: Rory Mulvaney Cc: zsh-users@zsh.org, Wayne Davison , Anthony R Fletcher Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, 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 i= n > general. > > So you could do: > > sleep 20000 & > sleep 20 & > pid=3D$! > 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=3D$! wait $pid This will wait for the sleep 20000 process, even if the sleep 20 has finished for long. Best regards, --=20 J=C3=A9r=C3=A9mie