MCE::Loop->init( max_workers => 2, chunk_size => 1, user_begin => sub { $SIG{'INT'} = sub { my $signal = shift; say "Hello from $signal: $$"; MCE->exit(0); }; }, on_post_exit => sub { my ($mce, $e) = @_; if ($e->{status} == 255) { MCE::Signal::stop_and_exit('__DIE__'); } } ); #### local $SIG{__DIE__} = sub { ... local $SIG{__DIE__}; local $\ = undef; my $_die_msg = (defined $_[0]) ? $_[0] : ''; print {*STDERR} $_die_msg; $self->exit(255, $_die_msg, $self->{_chunk_id}); }; #### eval { mce_loop { ... } @input }; # TODO: Today, $@ is not set at the manager level. # Thus, the eval block succeeds. Will fix this. if ( $@ ) { ... }