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 | |
|
RE: Re: Problems with fork or socket code???
by mortenal (Novice) on Aug 27, 2000 at 22:02 UTC |