We don't bite newbies here... much | |
PerlMonks |
Help with waitpid and forking ?by VicBalta (Scribe) |
on Sep 05, 2001 at 18:14 UTC ( [id://110295]=perlquestion: print w/replies, xml ) | Need Help?? |
VicBalta has asked for the wisdom of the Perl Monks concerning the following question: Hi I am writing a program that is Copying directories. But it has to do more the just two some times it does 6 or 8. So I wrote a program that forks a process and does them in pair of two's. So I have a for loop that forks off a process. But the problem that I am running into is that some times when one process finishes before the other process it ends that process. I am not sure how it is working with the fork. Im not sure if there is more than two forks at a time. And I always see the problem on the last copy. Maybee I think the problem might be that when it exits the for loop it exits the program and never waits for the other process to finish. Once it forks I want it to wait for both process's to finish before it goes on with the for loop. Is this the right thing to do? So that it will only have 2 process at a time. Or should I let it go on with the for loop? will it them make more than 2 process's? So if I do that can I put some thing after the for loop to wait for all process? I have tried putting in a waitpid. But it didn't not help the problem. Maybee I am setting it up wrong? So my questions on Forking are. 1) Is it best to do it this way with pairs of two or can you fork more process's off. 2) Can you set the limit of process to be forked off? 3) How can I make it wait for the process to finish. Can I make it wait for all process
Back to
Seekers of Perl Wisdom
|
|