Mario Roy > MCE-1.306 > MCE::Signal

Download:
MCE-1.306.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.306   Source   Latest Release: MCE-1.515

NAME ^

MCE::Signal - Provides tmp_dir creation & signal handling for Many-Core Engine.

VERSION ^

This document describes MCE::Signal version 1.306

SYNOPSIS ^

 use MCE::Signal qw( [-use_dev_shm] [-keep_tmp_dir] );

DESCRIPTION ^

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

stop_and_exit ( [ $exit_status | $signal ] )

 ## 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');

sys_cmd ( $command )

 ## 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);

EXAMPLES ^

 ## 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 );

REQUIREMENTS ^

Perl 5.8.0 or later

SOURCE ^

The source is hosted at: http://code.google.com/p/many-core-engine-perl/

AUTHOR ^

Mario E. Roy, <marioeroy AT gmail DOT com>

COPYRIGHT AND LICENSE ^

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/.

syntax highlighting: