Hi,

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


In reply to Continuing a program after Forking by Alatar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.