in reply to Problems with fork or socket code???

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")

Replies are listed 'Best First'.
RE: Re: Problems with fork or socket code???
by mortenal (Novice) on Aug 27, 2000 at 11:38 UTC
    Nope, no strict... If it did anything more than just crash, I would have put up the error message. Perl doesn't give an error message. Windows just spits out a 'fatal exception' or somesuch message (away from that box right now, or i'd say what it was), and the program dies, all open connections are closed. The only info I was able to get was where it crashed (by inserting on every line 'print (line_number);'). i hadn't thought of that ($!), but i'll try it out as soon as i get back to the box.
    Thanks,
       --tom
RE: Re: Problems with fork or socket code???
by mortenal (Novice) on Aug 27, 2000 at 22:02 UTC
    Windows says that Perl performed an illegal operation (invalid page fault in perl56.dll)...
    I put the code you suggested in, and it passes it without a problem...
    Thanks,
       --tom