lib/App/Sandy/InterlaceProcesses.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« lib/App/Sandy/DB/Schema/Result/StructuralVariation.pm ↑ Summary lib/App/Sandy/PieceTable.pm »
1 package App::Sandy::InterlaceProcesses;
2 # ABSTRACT: Interlaces the processe id for differents processes, actually for parent, child processes.
3  
4 1 ▶use App::Sandy::Base 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 our $VERSION = '0.25'; # VERSION
7  
8 has 'foreign_pid' => (
9 is => 'ro',
10 isa => 'ArrayRef[Int]',
11 required => 1
12 );
13  
14 has '_signal_stack' => (
15 traits => ['Array'],
16 is => 'ro',
17 isa => 'ArrayRef[Str]',
18 default => sub { [] },
19 handles => {
20 _add_signal => 'push',
21 signal_catched => 'count',
22 join_signals_received => 'join'
23 }
24 );
25  
26 sub BUILD {
27 my $self = shift;
28 $SIG{TERM} = $self->_handle_signal;
29 $SIG{INT} = $self->_handle_signal;
30 $SIG{QUIT} = $self->_handle_signal;
31 }
32  
33 sub _handle_signal {
34 my $self = shift;
35 return sub {
36 my $signame = shift;
37 unless ($self->signal_catched) {
38 $self->_add_signal($signame);
39 my $cnt = kill 'TERM' => @{ $self->foreign_pid };
40 }
41 };
42 }
43  
44 __END__
« lib/App/Sandy/DB/Schema/Result/StructuralVariation.pm ↑ Summary lib/App/Sandy/PieceTable.pm »