MCE::Signal - Provides tmp_dir creation & signal handling for Many-Core Engine.
This document describes MCE::Signal version 1.306
use MCE::Signal qw( [-use_dev_shm] [-keep_tmp_dir] );
This package configures $SIG{HUP,INT,PIPE,QUIT,TERM,XCPU,XFSZ} to point to stop_and_exit and creates a temporary directory. The main process and workers receiving said signals call stop_and_exit, which signals all workers to terminate, removes the temporary directory unless -keep_tmp_dir is specified, and terminates itself.
The location of temp dir resides under $ENV{TEMP} if defined, otherwise /dev/shm if writeable and -use_dev_shm is specified, or /tmp.
The temp dir resides under $ENV{TEMP}/mce/ when running Perl on Microsoft Windows.
Nothing is exported by default. Exportable are 1 variable and 2 subroutines:
$tmp_dir - Path to temporary directory. stop_and_exit - Described below sys_cmd - Described below
## Stops execution, removes temp directory and exits the entire ## application. Pass 'TERM' if wanting to terminate a spawned or ## running MCE state. MCE::Signal::stop_and_exit(1); MCE::Signal::stop_and_exit('TERM');
## Execute command and return the actual exit status. The calling ## process is also signaled if command caught SIGINT or SIGQUIT. my $exit_status = MCE::Signal::sys_cmd($command);
## Creates tmp_dir under /tmp use MCE::Signal; use MCE::Signal qw( :all ); ## Attempt to create tmp_dir under /dev/shm, otherwise under /tmp use MCE::Signal qw( -use_dev_shm ); ## Keep tmp_dir after script terminates use MCE::Signal qw( -keep_tmp_dir ); use MCE::Signal qw( -use_dev_shm -keep_tmp_dir );
Perl 5.8.0 or later
The source is hosted at: http://code.google.com/p/many-core-engine-perl/
Mario E. Roy, <marioeroy AT gmail DOT com>
Copyright (C) 2012 by Mario E. Roy
MCE::Signal is free software; you can redistribute it and/or modify it under the same terms as Perl itself http://dev.perl.org/licenses/.
To install MCE, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MCE
CPAN shell
perl -MCPAN -e shell install MCE
For more information on module installation, please visit the detailed CPAN module installation guide.