File Coverage

blib/lib/Check/Fork.pm
Criterion Covered Total %
statement 30 30 100.0
branch 10 10 100.0
condition 7 8 87.5
subroutine 6 6 100.0
pod 1 1 100.0
total 54 55 98.1


line stmt bran cond sub pod time code
1             package Check::Fork;
2              
3 5     5   177174 use base qw(Exporter);
  5         9  
  5         788  
4 5     5   45 use strict;
  5         10  
  5         142  
5 5     5   22 use warnings;
  5         6  
  5         263  
6              
7 5     5   24 use Config;
  5         16  
  5         252  
8 5     5   3419 use Readonly;
  5         32250  
  5         1716  
9              
10             our $ERROR_MESSAGE;
11             Readonly::Array our @EXPORT_OK => qw(check_fork $ERROR_MESSAGE);
12              
13             our $VERSION = 0.05;
14              
15             sub check_fork {
16 9     9 1 1100121 my ($config_hr, $os) = @_;
17              
18 9   100     40 $config_hr ||= \%Config;
19 9   66     31 $os ||= $^O;
20              
21 9 100 100     126 if ($config_hr->{'d_fork'}) {
    100          
    100          
22 2         8 return 1;
23             } elsif ($config_hr->{'d_pseudofork'}) {
24 1         4 return 1;
25             } elsif ($os eq 'MSWin32' || $os eq 'NetWare') {
26 5 100       18 if (! $config_hr->{'useithreads'}) {
27 2         5 $ERROR_MESSAGE = "$os: No interpreter-based threading implementation.";
28 2         6 return 0;
29             }
30 3 100       21 if ($config_hr->{'ccflags'} !~ /-DPERL_IMPLICIT_SYS/) {
31 1         4 $ERROR_MESSAGE = "$os: No PERL_IMPLICIT_SYS ccflags set.";
32 1         4 return 0;
33             }
34 2         6 return 1;
35             }
36 1         3 $ERROR_MESSAGE = 'No fork() routine available.';
37              
38 1         4 return 0;
39             }
40              
41             1;
42              
43             __END__