I'm using ActiveState 5.8.7 on Windows Server 2003 (service pack 1) and have been having trouble getting fork() emulation to behave stably in my scripts. Sometimes it works and sometimes it crashes Perl. I've got the problem narrowed down enough so that the following code will reliably tickle the bug (at least when run from cygwin/bash -- haven't tried the DOS shell yet):
The first call to Fork() works as expected printing two lines like:#!c:/Perl/bin/perl.exe sub Fork { my $pid; defined($pid = fork()) or die "Can't fork: $!\n"; if ($pid) {print "in parent ($$).\n"} else {print "in child ($$)\n";exit;} } sub show_block(&$) { my ($block, $message) = @_; $message =~ s/\n*$/\.\.\./o; print $message; my $result = eval { &$block }; $@ ? die "failed: $@\n" : print "done\n"; $result; } Fork(); show_block {Fork()} "testing forking in Windows"; print "done.\n";
in parent (2752). in child (-2348)
The wrapped Fork() call then causes a crash. With the code exactly as above I get a popup dialog box that says that basically Perl has crashed (it complains about Perl trying to access a memory location it doesn't have permission to read). If you separate out the the show_block sub into a separate file and use it, then the you also get a message to the shell window: "Bizarre SvTYPE[136] at line <line where the fork() call is> in file Test.pl". (If the script is called Test.pl.)
Has anyone else seen this? Is it worth reporting as a Perl bug to the PTB?
Thanks,
--DrWhy
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
Update: I've submitted this as a bug in AS's bug database: http://bugs.activestate.com/show_bug.cgi?id=40324
In reply to Perl Bug in Windows Fork Emulation? by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |