line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Command::Runner::Timeout; |
2
|
13
|
|
|
13
|
|
91
|
use strict; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
390
|
|
3
|
13
|
|
|
13
|
|
195
|
use warnings; |
|
13
|
|
|
|
|
38
|
|
|
13
|
|
|
|
|
597
|
|
4
|
13
|
|
|
13
|
|
101
|
use Time::HiRes (); |
|
13
|
|
|
|
|
13
|
|
|
13
|
|
|
|
|
3308
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
5
|
|
|
5
|
0
|
134
|
my ($class, $at, $kill) = @_; |
8
|
5
|
|
|
|
|
258
|
my $now = Time::HiRes::time(); |
9
|
5
|
|
|
|
|
247
|
bless { signaled => 0, at => $now + $at, at_kill => $now + $at + $kill }, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub signal { |
13
|
232
|
|
|
232
|
0
|
615
|
my $self = shift; |
14
|
232
|
50
|
66
|
|
|
1475
|
return if !$self->{at} && !$self->{at_kill}; |
15
|
232
|
|
|
|
|
1341
|
my $now = Time::HiRes::time(); |
16
|
232
|
100
|
100
|
|
|
1692
|
if ($self->{at} and $now >= $self->{at}) { |
17
|
5
|
|
|
|
|
93
|
$self->{at} = undef; |
18
|
5
|
|
|
|
|
21
|
$self->{signaled} = 1; |
19
|
5
|
|
|
|
|
197
|
return 'TERM'; |
20
|
|
|
|
|
|
|
} |
21
|
227
|
100
|
|
|
|
868
|
if ($now >= $self->{at_kill}) { |
22
|
1
|
|
|
|
|
26
|
$self->{at_kill} = undef; |
23
|
1
|
|
|
|
|
9
|
$self->{signaled} = 1; |
24
|
1
|
|
|
|
|
18
|
return 'KILL'; |
25
|
|
|
|
|
|
|
} |
26
|
226
|
|
|
|
|
1287
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub signaled { |
30
|
5
|
|
|
5
|
0
|
39
|
my $self = shift; |
31
|
5
|
|
|
|
|
89
|
$self->{signaled}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |