crashmonk has asked for the wisdom of the Perl Monks concerning the following question:

Just tring GET three http://perl.com/ at the same time. The next simple code crashes Perl.exe The instruction at "0x28073b9f" referenced memory at "0x03277b8c". The memory could not be "read". Click on OK to terminate the program Click on CANCEL to debug the program
use LWP::UserAgent; my $pid = fork(); for (1..3) { if ($pid = fork()) { next; } if (defined $pid) { GET(); exit; } else { die "Fork failed\n"; } } sub GET { my $ua = LWP::UserAgent->new; $ua->agent("Perl 5.6"); my $req = HTTP::Request->new("GET", "http://perl.com/"); my $res = $ua->request($req); if ($res->is_success) { print "OK\n"; return $res->content; } else { die "HTTP::Request error"; } }

Please help me resolve it.

ps:You can suggest to use ParallelUA, but it's not possible in my case.

Thanks.

2001-03-28 Edit by Corion: Moved to Seekers Of Perl Wisdom

Replies are listed 'Best First'.
Re: fork + HTTP::Request=perl.exe crash
by Corion (Patriarch) on Mar 28, 2001 at 19:09 UTC

    While (ActiveState) Perl does have an implementation of fork() for Win32, the fork() emulation does not always work, and you found such a case.

    There is not much hope for your stuff, because threads are experimental in Perl and don't do much good. You could write out a batch file which starts several instances of your script in parallel with the start batch command.

Re: fork + HTTP::Request=perl.exe crash
by $code or die (Deacon) on Mar 30, 2001 at 08:58 UTC