I have forked process running 3 different test process within a perl script. Each of these process runs for a few hours (forked). All the tests are supposed to finish before exiting the forked process and later publish the files. I am using "wait" to do this to avoid zombies. However intermittenly the "wait" doesnt seem to be very robust, since the forked process exits prematurely and the logs gets published (unfinished). I see in the background the zombie process A, B and C still running. Can anyone tell where is the issue. Here is the code I have put together:
if ($pid = fork()) { if ($pid2 = fork()) { <process A>; } else { <process B>; exit} } else { <process C> exit; } 1 while wait() > 0; <publish files>

Any clues to why this is happening would be appreciated. Is the wait() command all messed up? thanks


In reply to fork exits prematurely leaving zombies by perllearner

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.