Greetings brothers,

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

#!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";
The first call to Fork() works as expected printing two lines like:

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

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.