| 1 | package System::Timeout; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use vars qw(@ISA @EXPORT_OK $VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use IPC::Cmd qw(run); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | require Exporter; | |||||||||
| 8 | 3 | @ISA = qw(Exporter); | |||||||||
| 9 | 3 | @EXPORT_OK = qw(system timeout); | |||||||||
| 10 | |||||||||||
| 11 | 3 | our $VERSION = '0.07'; | |||||||||
| 12 | |||||||||||
| 13 | sub system | ||||||||||
| 14 | 2 | ▶ | { | ||||||||
|
Subroutine
system: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 15 | 2 | return timeout(@_); | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub timeout | ||||||||||
| 19 | 6 | ▶ | { | ||||||||
|
Subroutine
timeout: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||
| 20 | 6 | ▶ | if ($_[0] !~ /^\d+$/) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | { | ||||||||||
| 22 | 0 | my $r = CORE::system(@_); | |||||||||
| 23 | 0 | return $r; | |||||||||
| 24 | } | ||||||||||
| 25 | else | ||||||||||
| 26 | { | ||||||||||
| 27 | 6 | my $timeout_secs = shift @_; | |||||||||
| 28 | 6 | my $ref_cmd = \@_; | |||||||||
| 29 | 6 | my $r = run(command => $ref_cmd, timeout=> $timeout_secs, verbose=>1, ); | |||||||||
| 30 | 6 | ▶ | return 0 if $r; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 3 | ▶ | return 1 unless $r; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 3 | 1; | |||||||||
| 36 | |||||||||||
| 37 | __END__ | ||||||||||