line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Proc::ProcessTable::Process; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
40
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
178
|
|
4
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
161
|
|
5
|
6
|
|
|
6
|
|
29
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
645
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
require AutoLoader; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@ISA = qw(Exporter AutoLoader); |
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
@EXPORT = qw( |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
$VERSION = '0.02'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Preloaded methods go here. |
21
|
6
|
|
|
6
|
|
52
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
381
|
|
22
|
6
|
|
|
6
|
|
40
|
use File::Basename; |
|
6
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
3330
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub AUTOLOAD { |
25
|
33
|
|
|
33
|
|
14989
|
my $self = shift; |
26
|
33
|
50
|
|
|
|
71
|
my $type = ref($self) |
27
|
|
|
|
|
|
|
or croak "$self is not an object"; |
28
|
|
|
|
|
|
|
|
29
|
33
|
|
|
|
|
46
|
my $name = $AUTOLOAD; |
30
|
33
|
|
|
|
|
157
|
$name =~ s/.*://; # strip fully-qualified portion |
31
|
|
|
|
|
|
|
|
32
|
33
|
50
|
|
|
|
82
|
unless (exists $self->{$name} ) { |
33
|
0
|
|
|
|
|
0
|
croak "Can't access `$name' field in class $type"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
33
|
50
|
|
|
|
58
|
if (@_) { |
37
|
0
|
|
|
|
|
0
|
return $self->{$name} = shift; |
38
|
|
|
|
|
|
|
} else { |
39
|
33
|
|
|
|
|
144
|
return $self->{$name}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
######################################################## |
44
|
|
|
|
|
|
|
# Kill; just a wrapper for perl's kill at the moment |
45
|
|
|
|
|
|
|
######################################################## |
46
|
|
|
|
|
|
|
sub kill { |
47
|
1
|
|
|
1
|
1
|
1356
|
my ($self, $signal) = @_; |
48
|
1
|
50
|
|
|
|
19
|
die "PID " . $self->pid . " not valid." unless($self->pid =~ /^-?\d+$/); |
49
|
1
|
|
|
|
|
6
|
return( kill($signal, $self->pid) ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
######################################################## |
53
|
|
|
|
|
|
|
# Get/set accessors for priority and process group |
54
|
|
|
|
|
|
|
# (everything else is just a get, so handled by autoload) |
55
|
|
|
|
|
|
|
######################################################### |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Hmmm... These could use the perl functions to get if not stored on the object |
58
|
|
|
|
|
|
|
sub priority { |
59
|
0
|
|
|
0
|
1
|
|
my ($self, $priority) = @_; |
60
|
0
|
0
|
|
|
|
|
if( defined($priority) ){ |
61
|
0
|
|
|
|
|
|
setpriority(0, $self->pid, $priority); |
62
|
0
|
0
|
|
|
|
|
if( getpriority(0, $self->pid) == $priority ){ # Yuck; getpriority doesn't return a status |
63
|
0
|
|
|
|
|
|
$self->{priority} = $priority; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
|
return $self->{priority}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub pgrp { |
70
|
0
|
|
|
0
|
1
|
|
my ($self, $pgrp) = @_; |
71
|
0
|
0
|
|
|
|
|
if( defined($pgrp) ){ |
72
|
0
|
|
|
|
|
|
setpgrp($self->pid, $pgrp); |
73
|
0
|
0
|
|
|
|
|
if( getpgrp($self->pid) == $pgrp ){ # Ditto setpgrp |
74
|
0
|
|
|
|
|
|
$self->{pgrp} = $pgrp; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
|
return $self->{pgrp}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Apparently needed for mod_perl |
82
|
|
|
|
0
|
|
|
sub DESTROY {} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
__END__ |