use strict; use warnings; use feature 'say'; use Data::Dumper; ++$Data::Dumper::Sortkeys; use Time::HiRes qw/ usleep time /; use MCE::Shared; use MCE::Loop; my $pid = $$; say "PID $pid"; tie my %hash, 'MCE::Shared', (); $SIG{'INT'} = sub { kill 'TERM', -$$ }; $SIG{'TERM'} = sub { exit 0 }; MCE::Loop->init( max_workers => 6, chunk_size => 10 ); mce_loop { say "Forked child with $$"; my ( $mce, $chunk_ref, $chunk_id ) = @_; for ( @{ $chunk_ref } ) { $hash{ sprintf '%.2d %s', $_, $$ } = time; sleep 1; } } ( 0 .. 99 ); MCE::Loop->finish; END { say sprintf '%s %s (%s) in END', $$, time, $$ == $pid ? 'Parent' : 'Child'; if ( $$ == $pid ) { say 'Parent is ready to dump'; say 'Dumping: ' . Dumper \%hash; } } __END__

Here's an example of the output I am getting from my test program: PID 13209 Forked child with 13211 Forked child with 13212 Forked child with 13215 Forked child with 13214 Forked child with 13213 Forked child with 13216 ^C13211 1491567754.05168 (Child) in END 13216 1491567754.05169 (Child) in END 13213 1491567754.05382 (Child) in END 13212 1491567754.05404 (Child) in END 13214 1491567754.05448 (Child) in END 13209 1491567754.05601 (Parent) in END Parent is ready to dump 13215 1491567754.05627 (Child) in END ^C