File Coverage

blib/lib/Unix/Process.pm
Criterion Covered Total %
statement 29 30 96.6
branch 5 8 62.5
condition 2 3 66.6
subroutine 7 7 100.0
pod n/a
total 43 48 89.5


line stmt bran cond sub pod time code
1             package Unix::Process;
2              
3 1     1   6343 use strict;
  1         3  
  1         32  
4 1     1   6 use warnings;
  1         1  
  1         29  
5 1     1   5 use Carp;
  1         5  
  1         62  
6 1     1   1186 use IPC::System::Simple qw(capturex);
  1         18590  
  1         267  
7              
8             our $VERSION = '1.3101';
9             our $PS_PROGRAM = $ENV{PS_PATH} || '/bin/ps';
10             our $AUTOLOAD;
11              
12             1;
13              
14             sub AUTOLOAD {
15 2 50   2   1228 die "unprocessable garbage: $AUTOLOAD" unless $AUTOLOAD =~ m/::(\w+)$/;
16 2         9 my $sub = $1;
17              
18             my $f = sub {
19 2     2   6 my $this = shift;
20 2 100 66     13 my $pid = shift; $pid = $$ unless $pid and int($pid);
  2         183  
21 2         4 my $result = eval { capturex($PS_PROGRAM, '-o', $sub, '-p', $pid) };
  2         13  
22              
23 2 50       18449 croak $@ if $@;
24              
25 2 50       98 return $1 if $result =~ m/[\r\n]\s*(.+?)\s*[\r\n]/ms;
26 0         0 return;
27 2         31 };
28              
29             {
30 1     1   8 no strict 'refs';
  1         2  
  1         67  
  2         4  
31 2         3 *{$AUTOLOAD} = $f;
  2         14  
32             }
33 2         14 goto &$f;
34             }
35              
36             __END__