| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package P9Y::ProcessTable::Process::Base; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:BBYRD'; # AUTHORITY |
|
4
|
|
|
|
|
|
|
our $VERSION = '1.08'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
############################################################################# |
|
7
|
|
|
|
|
|
|
# Modules |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# use sanity; |
|
10
|
3
|
|
|
3
|
|
2032
|
use strict qw(subs vars); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
104
|
|
|
11
|
3
|
|
|
3
|
|
14
|
no strict 'refs'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
82
|
|
|
12
|
3
|
|
|
3
|
|
15
|
use warnings FATAL => 'all'; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
118
|
|
|
13
|
3
|
|
|
3
|
|
14
|
no warnings qw(uninitialized); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
103
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
13
|
use Moo; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
15
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
3067
|
use namespace::clean; |
|
|
3
|
|
|
|
|
38411
|
|
|
|
3
|
|
|
|
|
13
|
|
|
18
|
3
|
|
|
3
|
|
706
|
no warnings 'uninitialized'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
2274
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
############################################################################# |
|
21
|
|
|
|
|
|
|
# Attributes |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has _pt_obj => ( |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
required => 1, |
|
26
|
|
|
|
|
|
|
handles => [qw( |
|
27
|
|
|
|
|
|
|
fields |
|
28
|
|
|
|
|
|
|
_process_hash |
|
29
|
|
|
|
|
|
|
)], |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has pid => ( is => 'ro', required => 1 ); |
|
33
|
|
|
|
|
|
|
has uid => ( is => 'rwp', predicate => 1 ); |
|
34
|
|
|
|
|
|
|
has gid => ( is => 'rwp', predicate => 1 ); |
|
35
|
|
|
|
|
|
|
has euid => ( is => 'rwp', predicate => 1 ); |
|
36
|
|
|
|
|
|
|
has egid => ( is => 'rwp', predicate => 1 ); |
|
37
|
|
|
|
|
|
|
has suid => ( is => 'rwp', predicate => 1 ); |
|
38
|
|
|
|
|
|
|
has sgid => ( is => 'rwp', predicate => 1 ); |
|
39
|
|
|
|
|
|
|
has ppid => ( is => 'rwp', predicate => 1 ); |
|
40
|
|
|
|
|
|
|
has pgrp => ( is => 'rwp', predicate => 1 ); |
|
41
|
|
|
|
|
|
|
has sess => ( is => 'rwp', predicate => 1 ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has cwd => ( is => 'rwp', predicate => 1 ); |
|
44
|
|
|
|
|
|
|
has exe => ( is => 'rwp', predicate => 1 ); |
|
45
|
|
|
|
|
|
|
has root => ( is => 'rwp', predicate => 1 ); |
|
46
|
|
|
|
|
|
|
has cmdline => ( is => 'rwp', predicate => 1 ); |
|
47
|
|
|
|
|
|
|
has environ => ( is => 'rwp', predicate => 1 ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has minflt => ( is => 'rwp', predicate => 1 ); |
|
50
|
|
|
|
|
|
|
has cminflt => ( is => 'rwp', predicate => 1 ); |
|
51
|
|
|
|
|
|
|
has majflt => ( is => 'rwp', predicate => 1 ); |
|
52
|
|
|
|
|
|
|
has cmajflt => ( is => 'rwp', predicate => 1 ); |
|
53
|
|
|
|
|
|
|
has ttlflt => ( is => 'rwp', predicate => 1 ); |
|
54
|
|
|
|
|
|
|
has cttlflt => ( is => 'rwp', predicate => 1 ); |
|
55
|
|
|
|
|
|
|
has utime => ( is => 'rwp', predicate => 1 ); |
|
56
|
|
|
|
|
|
|
has stime => ( is => 'rwp', predicate => 1 ); |
|
57
|
|
|
|
|
|
|
has cutime => ( is => 'rwp', predicate => 1 ); |
|
58
|
|
|
|
|
|
|
has cstime => ( is => 'rwp', predicate => 1 ); |
|
59
|
|
|
|
|
|
|
has start => ( is => 'rwp', predicate => 1 ); |
|
60
|
|
|
|
|
|
|
has time => ( is => 'rwp', predicate => 1 ); |
|
61
|
|
|
|
|
|
|
has ctime => ( is => 'rwp', predicate => 1 ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has priority => ( is => 'rwp', predicate => 1 ); |
|
64
|
|
|
|
|
|
|
has fname => ( is => 'rwp', predicate => 1 ); |
|
65
|
|
|
|
|
|
|
has state => ( is => 'rwp', predicate => 1 ); |
|
66
|
|
|
|
|
|
|
has ttynum => ( is => 'rwp', predicate => 1 ); |
|
67
|
|
|
|
|
|
|
has ttydev => ( is => 'rwp', predicate => 1 ); |
|
68
|
|
|
|
|
|
|
has flags => ( is => 'rwp', predicate => 1 ); |
|
69
|
|
|
|
|
|
|
has threads => ( is => 'rwp', predicate => 1 ); |
|
70
|
|
|
|
|
|
|
has size => ( is => 'rwp', predicate => 1 ); |
|
71
|
|
|
|
|
|
|
has rss => ( is => 'rwp', predicate => 1 ); |
|
72
|
|
|
|
|
|
|
has wchan => ( is => 'rwp', predicate => 1 ); |
|
73
|
|
|
|
|
|
|
has cpuid => ( is => 'rwp', predicate => 1 ); |
|
74
|
|
|
|
|
|
|
has pctcpu => ( is => 'rwp', predicate => 1 ); |
|
75
|
|
|
|
|
|
|
has pctmem => ( is => 'rwp', predicate => 1 ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
has winpid => ( is => 'rwp', predicate => 1 ); |
|
78
|
|
|
|
|
|
|
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
|
1
|
|
|
1
|
0
|
1710
|
my ($self) = @_; |
|
95
|
1
|
|
|
|
|
14
|
my $hash = $self->_process_hash($self->pid); |
|
96
|
1
|
50
|
|
|
|
6
|
return unless $hash; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# use set methods |
|
99
|
1
|
|
|
|
|
7
|
foreach my $meth (keys %$hash) { |
|
100
|
34
|
100
|
|
|
|
68
|
next if $meth eq 'pid'; |
|
101
|
33
|
|
|
|
|
47
|
my $method = "_set_$meth"; |
|
102
|
33
|
|
|
|
|
181
|
$self->$method($hash->{$meth}); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
13
|
return $self; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub kill { |
|
109
|
1
|
|
|
1
|
0
|
12760
|
my ($self, $sig) = @_; |
|
110
|
1
|
|
|
|
|
61
|
return CORE::kill($sig, $self->pid); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
around pgrp => sub { |
|
114
|
|
|
|
|
|
|
my ($orig, $self, $pgrp) = @_; |
|
115
|
|
|
|
|
|
|
return $orig->($self) if @_ == 2; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
setpgrp($self->pid, $pgrp); |
|
118
|
|
|
|
|
|
|
$self->_set_pgrp($pgrp); |
|
119
|
|
|
|
|
|
|
}; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
around priority => sub { |
|
122
|
|
|
|
|
|
|
my ($orig, $self, $pri) = @_; |
|
123
|
|
|
|
|
|
|
return $orig->($self) if @_ == 2; |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
setpriority(0, $self->pid, $pri); |
|
126
|
|
|
|
|
|
|
$self->_set_priority($pri); |
|
127
|
|
|
|
|
|
|
}; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
42; |