Line 148 is part of a signal handler for TERM, so you should only get that when someone is killing the process. The error is probably caused because the kill has been raised at a point when $client_sock is invalid. You can never be sure when a signal occurs, so the results may be inconsistent.
The TERM signal seems to be raised by the script if the accept times out.

The way in which the code sends USR1 signals to the parent is convoluted, and I should say that I have not spent the time to fully understand it. Perhaps you should read the design document for this script ;-)

A Zombie is created when a child is waiting for the parent to acknowledge the CHLD signal raised when the child is ending. This is usually cleared by the parent using a wait or waitpid (this is UNIX architecture, not specific to Perl). In your code, it looks like a USR1 signal has to be raised for the parent to do a wait(), and that is probably the issue here. Normally I would expect to see a wait or waitpid in the final 'else' block (the parent) after the fork.

Incidently, if the fork should fail (usually that would be if the number of processes exceeds some limit) then it returns undef, which you are not testing for.

Update: improved wording.

In reply to Re: Script Creates Zombies by cdarke
in thread Script Creates Zombies by Anonymous Monk

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.