1MCE::Signal(3)        User Contributed Perl Documentation       MCE::Signal(3)
2
3
4

NAME

6       MCE::Signal - Temporary directory creation/cleanup and signal handling
7

VERSION

9       This document describes MCE::Signal version 1.838
10

SYNOPSIS

12        ## Creates tmp_dir under $ENV{TEMP} if defined, otherwise /tmp.
13
14        use MCE::Signal;
15
16        ## Attempts to create tmp_dir under /dev/shm if writable.
17
18        use MCE::Signal qw( -use_dev_shm );
19
20        ## Keeps tmp_dir after the script terminates.
21
22        use MCE::Signal qw( -keep_tmp_dir );
23        use MCE::Signal qw( -use_dev_shm -keep_tmp_dir );
24
25        ## MCE loads MCE::Signal by default when not present.
26        ## Therefore, load MCE::Signal first for options to take effect.
27
28        use MCE::Signal qw( -keep_tmp_dir -use_dev_shm );
29        use MCE;
30

DESCRIPTION

32       This package configures $SIG{ HUP, INT, PIPE, QUIT, and TERM } to point
33       to stop_and_exit and creates a temporary directory. The main process
34       and workers receiving said signals call stop_and_exit, which signals
35       all workers to terminate, removes the temporary directory unless
36       -keep_tmp_dir is specified, and terminates itself.
37
38       The location of the temp directory resides under $ENV{TEMP} if defined,
39       otherwise /dev/shm if writeable and -use_dev_shm is specified, or /tmp.
40       On Windows, the temp directory is made under $ENV{TEMP}/Perl-MCE/.
41
42       As of MCE 1.405, MCE::Signal no longer calls setpgrp by default. Pass
43       the -setpgrp option to MCE::Signal to call setpgrp.
44
45        ## Running MCE through Daemon::Control requires setpgrp to be called
46        ## for MCE releases 1.511 and below.
47
48        use MCE::Signal qw(-setpgrp);   ## Not necessary for MCE 1.512 and above
49        use MCE;
50
51       The following are available options and their meanings.
52
53        -keep_tmp_dir     - The temporary directory is not removed during exiting
54                            A message is displayed with the location afterwards
55
56        -use_dev_shm      - Create the temporary directory under /dev/shm
57        -no_kill9         - Do not kill -9 after receiving a signal to terminate
58
59        -setpgrp          - Calls setpgrp to set the process group for the process
60                            This option ensures all workers terminate when reading
61                            STDIN for MCE releases 1.511 and below.
62
63                               cat big_input_file | ./mce_script.pl | head -10
64
65                            This works fine without the -setpgrp option:
66
67                               ./mce_script.pl < big_input_file | head -10
68
69       Nothing is exported by default. Exportable are 1 variable and 2
70       subroutines.
71
72        use MCE::Signal qw( $tmp_dir stop_and_exit sys_cmd );
73        use MCE::Signal qw( :all );
74
75        $tmp_dir          - Path to the temporary directory.
76        stop_and_exit     - Described below
77        sys_cmd           - Described below
78
79   stop_and_exit ( [ $exit_status | $signal ] )
80       Stops execution, removes temp directory, and exits the entire
81       application.  Pass 'INT' to terminate a spawned or running MCE session.
82
83        MCE::Signal::stop_and_exit(1);
84        MCE::Signal::stop_and_exit('INT');
85
86   sys_cmd ( $command )
87       The system function in Perl ignores SIGINT and SIGQUIT. These 2 signals
88       are sent to the command being executed via system() but not back to the
89       underlying Perl script. For this reason, sys_cmd was added to
90       MCE::Signal.
91
92        ## Execute command and return the actual exit status. The perl script
93        ## is also signaled if command caught SIGINT or SIGQUIT.
94
95        use MCE::Signal qw(sys_cmd);   ## Include before MCE
96        use MCE;
97
98        my $exit_status = sys_cmd($command);
99

INDEX

101       MCE, MCE::Core
102

AUTHOR

104       Mario E. Roy, <marioeroy AT gmail DOT com>
105
106
107
108perl v5.28.1                      2019-01-23                    MCE::Signal(3)
Impressum