line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::SimulateReads::InterlaceProcesses; |
2
|
|
|
|
|
|
|
# ABSTRACT: Interlaces the processe id for differents processes, actually for parent, child processes. |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
2537
|
use App::SimulateReads::Base 'class'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
9
|
|
|
|
|
|
|
# Static variables |
10
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
11
|
|
|
|
|
|
|
my $SIGNAL_ACM = 0; |
12
|
|
|
|
|
|
|
my @SIGNALS_RECEIVED; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'foreign_pid' => (is => 'ro', isa => 'ArrayRef[Int]', required => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
17
|
|
|
|
|
|
|
# CLASS: InterlaceProcesses |
18
|
|
|
|
|
|
|
# METHOD: BUILD (Moose) |
19
|
|
|
|
|
|
|
# PARAMETERS: Void |
20
|
|
|
|
|
|
|
# RETURNS: Void |
21
|
|
|
|
|
|
|
# DESCRIPTION: Trap signals |
22
|
|
|
|
|
|
|
# THROWS: no exceptions |
23
|
|
|
|
|
|
|
# COMMENTS: none |
24
|
|
|
|
|
|
|
# SEE ALSO: n/a |
25
|
|
|
|
|
|
|
#=============================================================================== |
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
8
|
|
|
8
|
0
|
55
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
|
|
70
|
$SIG{TERM} = $self->_handle_signal; |
30
|
8
|
|
|
|
|
78
|
$SIG{INT} = $self->_handle_signal; |
31
|
8
|
|
|
|
|
25
|
$SIG{QUIT} = $self->_handle_signal; |
32
|
|
|
|
|
|
|
} ## --- end sub BUILD |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
35
|
|
|
|
|
|
|
# CLASS: InterlaceProcesses |
36
|
|
|
|
|
|
|
# METHOD: signal_catched |
37
|
|
|
|
|
|
|
# PARAMETERS: Void |
38
|
|
|
|
|
|
|
# RETURNS: Int >= 0 |
39
|
|
|
|
|
|
|
# DESCRIPTION: Returns the number of times it receives a termination signal |
40
|
|
|
|
|
|
|
# THROWS: no exceptions |
41
|
|
|
|
|
|
|
# COMMENTS: none |
42
|
|
|
|
|
|
|
# SEE ALSO: n/a |
43
|
|
|
|
|
|
|
#=============================================================================== |
44
|
|
|
|
|
|
|
sub signal_catched { |
45
|
1714
|
|
|
1714
|
0
|
44364
|
return $SIGNAL_ACM; |
46
|
|
|
|
|
|
|
} ## --- end sub signal_catched |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
49
|
|
|
|
|
|
|
# CLASS: InterlaceProcesses |
50
|
|
|
|
|
|
|
# METHOD: signal_received |
51
|
|
|
|
|
|
|
# PARAMETERS: Void |
52
|
|
|
|
|
|
|
# RETURNS: Str |
53
|
|
|
|
|
|
|
# DESCRIPTION: Returns a string with the signal names received |
54
|
|
|
|
|
|
|
# THROWS: no exceptions |
55
|
|
|
|
|
|
|
# COMMENTS: none |
56
|
|
|
|
|
|
|
# SEE ALSO: n/a |
57
|
|
|
|
|
|
|
#=============================================================================== |
58
|
|
|
|
|
|
|
sub signal_received { |
59
|
0
|
|
|
0
|
0
|
0
|
return join(", " => @SIGNALS_RECEIVED); |
60
|
|
|
|
|
|
|
} ## --- end sub signal_received |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#=== CLASS METHOD ============================================================ |
63
|
|
|
|
|
|
|
# CLASS: InterlaceProcesses |
64
|
|
|
|
|
|
|
# METHOD: _handle_signal (PRIVATE) |
65
|
|
|
|
|
|
|
# PARAMETERS: Void |
66
|
|
|
|
|
|
|
# RETURNS: Ref Code |
67
|
|
|
|
|
|
|
# DESCRIPTION: Sets a handler to trapping signal. If termination signal is received |
68
|
|
|
|
|
|
|
# it kills the interlaced processes |
69
|
|
|
|
|
|
|
# THROWS: no exceptions |
70
|
|
|
|
|
|
|
# COMMENTS: none |
71
|
|
|
|
|
|
|
# SEE ALSO: n/a |
72
|
|
|
|
|
|
|
#=============================================================================== |
73
|
|
|
|
|
|
|
sub _handle_signal { |
74
|
24
|
|
|
24
|
|
57
|
my $self = shift; |
75
|
|
|
|
|
|
|
return sub { |
76
|
0
|
|
|
0
|
|
|
my $signame = shift; |
77
|
0
|
|
|
|
|
|
push @SIGNALS_RECEIVED => $signame; |
78
|
0
|
|
|
|
|
|
$SIGNAL_ACM++; |
79
|
0
|
|
|
|
|
|
my $cnt = kill 'TERM' => @{ $self->foreign_pid }; |
|
0
|
|
|
|
|
|
|
80
|
24
|
|
|
|
|
734
|
}; |
81
|
|
|
|
|
|
|
} ## --- end sub _handle_signal |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=pod |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=encoding UTF-8 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
App::SimulateReads::InterlaceProcesses - Interlaces the processe id for differents processes, actually for parent, child processes. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 VERSION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
version 0.06 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Thiago L. A. Miller <tmiller@mochsl.org.br> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Teaching and Research Institute from SÃrio-Libanês Hospital. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software, licensed under: |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |