Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

will all spawnv complete at wait() ?

Status
Not open for further replies.

dans45

Technical User
Feb 13, 2003
43
0
0
US
Hi, Under RHAT 9. I'm executing several groups of processes that must complete in the same sequence in which they are started. I'm using wait() to try to accomplish this...
example...
program1.py
Print "Step 1"
for x in list
spawnv(..function1...x + x....)
wait() #these must complete before Step 2 starts
Print "Step 2"
for x in list
spawnv(..function2...x + x....)
wait()
When I execute program1.py and redirect the output for analysis...
python program1.py 1>out1 2>out2
out1 seems to indicate that function1 does start first and in general it completes prior to function2 but this is not always the case. The output may look like...
function1 start x
function1 start xx
function1 start xxx
function1 end x
function2 start x
function1 end xx
function2 start xx
function1 end xxx
function2 start xxx
Step 1
Step 2
function2 end x
function2 end xx
function2 end xxx
So it appears that the wait() is not working.
Shouldn't all of the spawnv statements prior to a wait() complete before the continuing beyond the wait?
Thanks for your help.


 
According to the documentation:
wait()
Wait for completion of a child process
it says *a* child process, not *all* child processes.

Plus, it returns the pid of the child the completed, indicating that it's probably a signal handler waiting for SIGCHILD, so it will trap the exit of the first process to complete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top