delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-0.3 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <4DD40377.80600@ece.cmu.edu> |
Date: | Wed, 18 May 2011 13:35:51 -0400 |
From: | Ryan Johnson <ryanjohn AT ece DOT cmu DOT edu> |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 |
MIME-Version: | 1.0 |
To: | "C. Woody Butler" <charles DOT butlerjr AT constellation DOT com> |
CC: | cygwin AT cygwin DOT com |
Subject: | Re: trying to get the process id for a spawned process to wait for it |
References: | <loom DOT 20110517T203754-549 AT post DOT gmane DOT org> |
In-Reply-To: | <loom.20110517T203754-549@post.gmane.org> |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
On 2:59 PM, C. Woody Butler wrote: > Hi - I'm trying to launch a set number of threads, > wait for them to finish, launch another set of > threads, wait and repeat until there's no more input. > > so - I've got this (this is in the middle > of a loop reading a file): > > Jobs=$Jobs + 1 What shell are you using? In bash, at least, the above won't work -- you want Jobs=((Jobs+1)) > /tibcoresources/appmanage.exe<<lots of params>> & > PID=$! > echo $PID is the process > > if [[ $Jobs -gt 2 ]] > then > { > echo pausing > wait $PID > Jobs=0 > echo starting > } > fi > > But - I don't get anything back from $! > so the wait doesn't wait and I end up > launching a bunch of processes and taking > down the server, etc, etc, etc. Just to be sure, you've confirmed that the problem arises because the if-then body runs with an empty $PID? Do the two echo commands fire? Ryan -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |