The answer is 'yes'. Zombies are created when a child has exited, but the parent has not wait()ed for it yet. Zombies are no good (they tend to eat nice friendly old ladies, for example). One way of ensuring that the parent always acts correctly upon the death of a child is installing a signal handler for SIGCHLD:
$SIG{'CHLD'}=sub { my $pid=wait(); if ($pid == -1 ) { print "SIGCHLD handler called without dead child.\n"; return; } print "Child $pid exited with $?\n"; }
That way, whatever else the parent is doing, it will normally always catch a SIGCHLD. The only exception to this is if the parent is in uninterruptible sleep (e.g. when it's waiting on an NFS op on a filesystem whose server has gone away) - then it becomes night of the living dead :).

Update: In the case of an open()ed child, as apparently the OP is using (bad robartes, I had parsed the snippet as a standard fork and exec), see Improv's remark. However, installing a SIGCHLD handler can never hurt, for example in the case where the child process abnormally (or even normally) terminates before the parent closes the filehandle.

CU
Robartes-


In reply to Re: open(KID, "-|") and wait()? by robartes
in thread open(KID, "-|") and wait()? by edan

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.