My first questions: you are aware of IO::Select and/or select? (You don't need to fork to be able to use/process more then one client connection.)

There certainly are some issues with this code, but none seem to be critical for the code (as in it's still broken)...

First note: on v5.6.1 the parent does not die. on v5.8.7 (and v5.9.2) the parent does die.

Second: in both programs you are missing: use warnings;. If you are using warnings then you will see one thing in the code: use of uninitalised value in numer gt. Why? Because you have: while (my $kid > 0). Creating a value, not assigning anything to it and then comparing it with 0 is silly. Also note that your while-loop does not assign anything to $kid. (Meaning you should do something more then just removing the my).

Then the client: it's missing use strict; and use warnings;. use warnings is important in this case if you are using it on v5.6.1 (as I initialy was). Why? Because it doesn't work. It seems that <$socket> only works if $socket is a lexical variable (again, on v5.6.1). And that's not the case.


In reply to Re: Fork parent process dies unexpectedly by Animator
in thread Fork parent process dies unexpectedly by iang

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.