Have you heard of the concept of simplifying to a small test case? Anyway that said AFAIKS the problem is that in your incredibly misnamed new_thread routine you are doing this:

if ( $pid = fork() ) { $threads++; # you mean kids return $pid } # this is kid code # kid does socket but.....then...... exit($result);

So the child process is exiting but you are not decrementing the '$thread' count, at least in the code presented. Nor are you communicating its death to the parent. So the reason you are getting a no children error is simple -> *there are no children* because they have finished but the parent simply does not know it.

At a glance I don't see how you think the IPC between parent and child is going to work, and given the length of your sample and what I find really inaccurate and annoying names (ie a forked kid is not a thread) a glance is all it is going to get. When you fork parent and child get copies of all data and handles. Independent* copies so if the kid does stuff to the data the parents data remains unchanged.

* yes I understand COW.

cheers

tachyon


In reply to Re: mixing multisockets and forks by tachyon
in thread mixing multisockets and forks by fxmakers

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.