ProcessTable/Process/Base.pm

filter: Statementstmt 84.2% 75 / 89 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 2 totaltotal 75.6% 84 / 111 CC 6 SCAR 15.3
CC
6
Cov
77%
refresh
11.3
__ANON__
6.0
__ANON__
6.0
CRAP 4.6
« ProcessTable/Role/Table/OS/freebsd.pm ↑ Summary ProcessTable/Role/Table/OS/VMS.pm »
1 package P9Y::ProcessTable::Process::Base;
2  
3 3 our $AUTHORITY = 'cpan:BBYRD'; # AUTHORITY
4 3 our $VERSION = '1.06_01'; # VERSION
5  
6 #############################################################################
7 # Modules
8  
9 # use sanity;
10 3 ▶use strict qw(subs vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 #############################################################################
21 # Attributes
22  
23 3 has _pt_obj => (
24 is => 'ro',
25 required => 1,
26 handles => [qw(
27 fields
28 _process_hash
29 )],
30 );
31  
32 3 has pid => ( is => 'ro', required => 1 );
33 3 has uid => ( is => 'rwp', predicate => 1 );
34 3 has gid => ( is => 'rwp', predicate => 1 );
35 3 has euid => ( is => 'rwp', predicate => 1 );
36 3 has egid => ( is => 'rwp', predicate => 1 );
37 3 has suid => ( is => 'rwp', predicate => 1 );
38 3 has sgid => ( is => 'rwp', predicate => 1 );
39 3 has ppid => ( is => 'rwp', predicate => 1 );
40 3 has pgrp => ( is => 'rwp', predicate => 1 );
41 3 has sess => ( is => 'rwp', predicate => 1 );
42  
43 3 has cwd => ( is => 'rwp', predicate => 1 );
44 3 has exe => ( is => 'rwp', predicate => 1 );
45 3 has root => ( is => 'rwp', predicate => 1 );
46 3 has cmdline => ( is => 'rwp', predicate => 1 );
47 3 has environ => ( is => 'rwp', predicate => 1 );
48  
49 3 has minflt => ( is => 'rwp', predicate => 1 );
50 3 has cminflt => ( is => 'rwp', predicate => 1 );
51 3 has majflt => ( is => 'rwp', predicate => 1 );
52 3 has cmajflt => ( is => 'rwp', predicate => 1 );
53 3 has ttlflt => ( is => 'rwp', predicate => 1 );
54 3 has cttlflt => ( is => 'rwp', predicate => 1 );
55 3 has utime => ( is => 'rwp', predicate => 1 );
56 3 has stime => ( is => 'rwp', predicate => 1 );
57 3 has cutime => ( is => 'rwp', predicate => 1 );
58 3 has cstime => ( is => 'rwp', predicate => 1 );
59 3 has start => ( is => 'rwp', predicate => 1 );
60 3 has time => ( is => 'rwp', predicate => 1 );
61 3 has ctime => ( is => 'rwp', predicate => 1 );
62  
63 3 has priority => ( is => 'rwp', predicate => 1 );
64 3 has fname => ( is => 'rwp', predicate => 1 );
65 3 has state => ( is => 'rwp', predicate => 1 );
66 3 has ttynum => ( is => 'rwp', predicate => 1 );
67 3 has ttydev => ( is => 'rwp', predicate => 1 );
68 3 has flags => ( is => 'rwp', predicate => 1 );
69 3 has threads => ( is => 'rwp', predicate => 1 );
70 3 has size => ( is => 'rwp', predicate => 1 );
71 3 has rss => ( is => 'rwp', predicate => 1 );
72 3 has wchan => ( is => 'rwp', predicate => 1 );
73 3 has cpuid => ( is => 'rwp', predicate => 1 );
74 3 has pctcpu => ( is => 'rwp', predicate => 1 );
75 3 has pctmem => ( is => 'rwp', predicate => 1 );
76  
77 3 has winpid => ( is => 'rwp', predicate => 1 );
78 3 has winexe => ( is => 'rwp', predicate => 1 );
79  
80 #sub fields {
81 # return ( qw/
82 # pid uid gid euid egid suid sgid ppid pgrp sess
83 # cwd exe root cmdline environ
84 # minflt cminflt majflt cmajflt ttlflt cttlflt utime stime cutime cstime start time ctime
85 # priority fname state ttynum ttydev flags threads size rss wchan cpuid pctcpu pctmem
86 # winpid winexe
87 # / );
88 #}
89  
90 #############################################################################
91 # Common Methods (may potentially be redefined with OS-specific ones)
92  
93 sub refresh {
94 0 ▶ my ($self) = @_;
Subroutine refresh: not called CC=4 SCAR=24.2
Pod undocumented
95 0 my $hash = $self->_process_hash($self->pid);
96 0 ▶ return unless $hash;
Branch: 1 branch
BranchTrueFalseTotal
unless $hash 0 0 0
97  
98 # use set methods
99 0 foreach my $meth (keys %$hash) {
100 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
101 0 ▶ $self->("_set_$meth")($hash->{$meth}) if (exists $hash->{$meth});
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash->{$meth} 0 0 0
102 }
103  
104 0 return $self;
105 }
106  
107 sub kill {
108 1 ▶ my ($self, $sig) = @_;
Subroutine kill: called CC=1 SCAR=0.0
Pod undocumented
109 1 return CORE::kill($sig, $self->pid);
110 }
111  
112 around pgrp => sub {
113 0 ▶ my ($orig, $self, $pgrp) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
114 0 ▶ return $orig->($self) if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 0 0 0
115  
116 0 setpgrp($self->pid, $pgrp);
117 0 $self->_set_pgrp($pgrp);
118 3 };
119  
120 around priority => sub {
121 0 ▶ my ($orig, $self, $pri) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
122 0 ▶ return $orig->($self) if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 0 0 0
123  
124 0 setpriority(0, $self->pid, $pri);
125 0 $self->_set_priority($pri);
126 3 };
127  
128 3 42;
« ProcessTable/Role/Table/OS/freebsd.pm ↑ Summary ProcessTable/Role/Table/OS/VMS.pm »