When I first looked at your question, I couldn't see the problem, you wanted to start something then wait "until" it was done (waitpid). Ok, er, oh...you want to some code to execute while you are in the wait call?

Er, um you'll need to have someone else do that cuz, you just told it to wait until it's done.

(or, like others have said, 1) waitpid is 'blocking' ....(that's what you wanted? No? Ooops...), so either use non-blocking form of waitpid OR have something else (process/thread) do the calculate loop. Depends on what the calc routine does and how it interacts with the existing program variables as to whether or not threads or a process would be better.

If you use the non-waiting form of 'waitpid', be sure to read the 'perlipc' manpage to get the right example to guard against "gotcha's", like signals dropping between the cracks.

Basically you have to use 'waitpid' IN a child process you setup before you fork. Examples are in the manpage.


In reply to Re: Perl Forking : perform some action until child process dies by perl-diddler
in thread Perl Forking : perform some action until child process dies by robrt

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.