Alatar has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to use Perl for loadtesting purposes, which means that I need to run simultaneous processes and then return for stat gathering. Now I have the process forking working, but my problem is returning to gather the stats. I am using the following code to wait for all child processes to finish, and to be doubly sure I'm killing the processes after they finish:
1 while wait() > 0;
foreach my $child (keys %pid) {
kill($child);
}
The idea was that I could kill the child processes and continue with subsequent code. Unfortunately, that's not what's happening. The child process does not end until it has run a full instance of the program (including the above code and any subsequent code). The end result of this is that any code after the forks is being run multiple times.
Is there any way around this? How do I Fork multiple parralel processes and then return to a single process? An added complication is that this needs to run on a vanilla Test System (Solaris Sybase) without adding any Perl Modules or configuring for threading.
Any help much appreciated!
Thanks,
Alatar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Continuing a program after Forking
by Ido (Hermit) on Feb 06, 2002 at 12:47 UTC | |
|
Re: Continuing a program after Forking
by data64 (Chaplain) on Feb 06, 2002 at 12:58 UTC |