File Coverage

lib/App/Sandy/InterlaceProcesses.pm
Criterion Covered Total %
statement 9 14 64.2
branch 0 2 0.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 12 21 57.1


line stmt bran cond sub pod time code
1             package App::Sandy::InterlaceProcesses;
2             # ABSTRACT: Interlaces the processe id for differents processes, actually for parent, child processes.
3              
4 6     6   42 use App::Sandy::Base 'class';
  6         12  
  6         43  
5              
6             our $VERSION = '0.22'; # 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 8     8 0 30 my $self = shift;
28 8         104 $SIG{TERM} = $self->_handle_signal;
29 8         94 $SIG{INT} = $self->_handle_signal;
30 8         39 $SIG{QUIT} = $self->_handle_signal;
31             }
32              
33             sub _handle_signal {
34 24     24   102 my $self = shift;
35             return sub {
36 0     0     my $signame = shift;
37 0 0         unless ($self->signal_catched) {
38 0           $self->_add_signal($signame);
39 0           my $cnt = kill 'TERM' => @{ $self->foreign_pid };
  0            
40             }
41 24         966 };
42             }
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             App::Sandy::InterlaceProcesses - Interlaces the processe id for differents processes, actually for parent, child processes.
53              
54             =head1 VERSION
55              
56             version 0.22
57              
58             =head1 AUTHORS
59              
60             =over 4
61              
62             =item *
63              
64             Thiago L. A. Miller <tmiller@mochsl.org.br>
65              
66             =item *
67              
68             J. Leonel Buzzo <lbuzzo@mochsl.org.br>
69              
70             =item *
71              
72             Felipe R. C. dos Santos <fsantos@mochsl.org.br>
73              
74             =item *
75              
76             Helena B. Conceição <hconceicao@mochsl.org.br>
77              
78             =item *
79              
80             Gabriela Guardia <gguardia@mochsl.org.br>
81              
82             =item *
83              
84             Fernanda Orpinelli <forpinelli@mochsl.org.br>
85              
86             =item *
87              
88             Pedro A. F. Galante <pgalante@mochsl.org.br>
89              
90             =back
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is Copyright (c) 2018 by Teaching and Research Institute from Sírio-Libanês Hospital.
95              
96             This is free software, licensed under:
97              
98             The GNU General Public License, Version 3, June 2007
99              
100             =cut