The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

VERSION

This document describes MCE::Signal version 1.007

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 or workers receiving said signal calls 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 tmp dir resides under $ENV{TEMP} if configured, otherwise /dev/shm if available and -use_dev_shm is specified, or /tmp.

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

 sys_cmd           - Execute command and return the actual exit status.
 stop_and_exit     - Stops execution, removes tmp directory and exits
                     the entire application.

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.