ibm1620,

I have lots of code for using signals to control forked children. Since about 3-4 years ago, I have stopped using signals and that code! Trying to have the same Perl script be able to run on different *nixes just doesn't work like it used to.

What I have found to work very well for me is to use 'kill 0' in the parent code to tell if the child still exists I use 'usleep' to wait for a few milliseconds between tests in a 'while (1)' loop. I keep the child pids in a hash with the values being the initial time of the fork. I usually test for the memory usage of each child and if it starts to grow too quickly, I try to halt it gently and if it doesn't exit than I force kill the process. (Note: That hasn't happened yet, but it may.)

I'm not saying you can't get it to work on one distribution of *nix, but it seems that the different vendors are *impoving* the signal process all the time :-). YMMY.

Update: Corrected 'fork 0' to 'kill 0' as AM noticed.

Regards...Ed

"Well done is better than well said." - Benjamin Franklin


In reply to Re: Managing the fork/execing and reaping of child processes by flexvault
in thread Managing the fork/execing and reaping of child processes by ibm1620

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.