Your code calls the perl fork function six times, three of which are controlled by returning the pid and issuing a waitpid to hold up parent execution until completion of the child. But not only will these children run through to the end of the code unchecked, but the three uncontrolled forks will triplicate everything from where they are placed - I don't dare to test (or rather inflict) your code on my machines under these circumstances, but if you were to place a sleep 60 at the end of the code and then repeatedly examine what is running using the ps command, I wager you will see far more parallel processes being spawned than you imagine should take place even after reading the above definition.
To fix this code in the simplest way:
1) yes, as already replied, replace all exec with system BUT
2) also remove all "unless fork" lines reducing the code to a single non-parallel process.
-M
Free your mind
In reply to Re: Waiting for an External Program to Finish Executing
by Moron
in thread Waiting for an External Program to Finish Executing
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |