Can someone please explain why why the following code doesn't work as intended? It works fine on UNIX (Perl 5.8.0 on Sun Solaris 2.6 and 8), but not on cursed Windows:
#!perl

use strict;

use Errno qw( EAGAIN      );
use POSIX qw( strftime    );
use POSIX qw( :sys_wait_h );

use Data::Dumper;

my $childPid;
my %reapedChildren = ();

FORK: {

   local $SIG{ CHLD } = \&reaper;

   if ( $childPid = fork ) { # parent code
      sleep 1 until ( %reapedChildren );
      print Dumper \%reapedChildren;
      exit 0;
   } elsif ( defined $childPid ) { # child code
      system 'cd';
      system 'sleep 3';
      system 'cd';
   } elsif ( $! == EAGAIN ) {
      sleep 5;
      redo FORK;
   } else { # unknown fork error
      die "can't fork: $!\n";
   }
}

sub reaper {
   my $pid = 0;
   while ( $pid != -1 ) {
      $pid = waitpid( -1, &POSIX::WNOHANG );
      $reapedChildren{ $pid } = 1 if ( $pid > 0 );
   }
}

In reply to fork() and signal handlers on Windows by BunMan

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.