the program crashes

That is always a lousy description of what happened. Does it give you an error message?

Taking a guess, did it complain about not being able to use "undef" as an array reference?

my ($ready) = IO::Select->select($readable, undef, undef, undef); foreach my $s (@$ready) {

If you read the documentation for IO::Select->select(), you will see that it returns either a list of three references to arrays or an empty list. In the later case, $ready will end up undef. I'm guessing you have a use strict that you didn't show us and trying to do @$ready on undef kills your script.

What you should do is something like:

my ($ready) = IO::Select->select($readable, undef, undef, undef); die "IO::Select->select() failed: $!\n" unless $ready; foreach my $s (@$ready) {

The $! bit will tell you why the select call failed. Once you have that, you or someone here will probably be able to figure out why it is failing or at least what to try next.

If I didn't guess right, then give us more information and we'll probably be able to help.

I suspect the problem stems from the child using a file handle (or a Win32 socket in particular) opened by the parent. I haven't investigated the details of the fork() emulation that ActivePerl now has. So I'm not sure how many Unixisms are properly emulated by it. I'm not sure what caveats there are when structures are copied to the new interpretter that is built in the new thread, especially when it comes to file handles and sockets.

        - tye (but my friends call me "Tye")

In reply to Re: Problems with fork or socket code??? by tye
in thread Problems with fork or socket code??? by mortenal

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.