This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: trying to get the process id for a spawned process to wait for it


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]