I'll try rewriting my code with waitpid in the parent.

Although I have experience with perl, I am a novice in forking processes, etc. So i don't know if this is the best, in my case 'best' means stability, code for doing what I want to do.

My reasoning for having the child wait for the grandchild is two-fold. One the grandchild is a non-perl program that runs for ~1 minute. So if I didn't use 'system', which forks and waits for its child to finish, and used 'exec' instead (which as I understand it just executes the command, and does not wait for its child to finish) then I would put multiple jobs (each needing heavy CPU usage) running on one node, instead of running them serially. This is extremelly undesirable outcome for me. The second reason I have the child wait for the grandchild is that I need to analyze the output of the 24 non-perl programs when they are finished, the only way I know how to do that is in side the child signal reaper.

Please let me know if my assumptions above regarding 'exec' are incorrect. If I could use your suggestion and get rid of the defunct rsh processes, while still meeting the criteria above, please let me know.

Thanks!


In reply to Re^2: rsh <defunct> processes appear when using fork and system calls by whatwhat
in thread rsh <defunct> processes appear when using fork and system calls by whatwhat

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.