| 1 | package Proc::ProcessTable::Process; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 6 | require Exporter; | |||||||||
| 8 | 6 | require AutoLoader; | |||||||||
| 9 | |||||||||||
| 10 | 6 | @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 | 6 | @EXPORT = qw( | |||||||||
| 15 | |||||||||||
| 16 | ); | ||||||||||
| 17 | 6 | $VERSION = '0.02'; | |||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | # Preloaded methods go here. | ||||||||||
| 21 | 6 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 6 | ▶ | use File::Basename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 30 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=15.2
| |||||||||||
| 25 | 30 | my $self = shift; | |||||||||
| 26 | 30 | ▶ | my $type = ref($self) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | or croak "$self is not an object"; | ||||||||||
| 28 | |||||||||||
| 29 | 30 | my $name = $AUTOLOAD; | |||||||||
| 30 | 30 | $name =~ s/.*://; # strip fully-qualified portion | |||||||||
| 31 | |||||||||||
| 32 | 30 | ▶ | unless (exists $self->{$name} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | croak "Can't access `$name' field in class $type"; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 30 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | return $self->{$name} = shift; | |||||||||
| 38 | } else { | ||||||||||
| 39 | 30 | return $self->{$name}; | |||||||||
| 40 | } | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | ######################################################## | ||||||||||
| 44 | # Kill; just a wrapper for perl's kill at the moment | ||||||||||
| 45 | ######################################################## | ||||||||||
| 46 | 1 | ▶ | sub kill { | ||||||||
|
Subroutine
kill: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 47 | 1 | my ($self, $signal) = @_; | |||||||||
| 48 | 1 | ▶ | die "PID " . $self->pid . " not valid." unless($self->pid =~ /^-?\d+$/); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 1 | 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 | 0 | ▶ | sub priority { | ||||||||
|
Subroutine
priority: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 59 | 0 | my ($self, $priority) = @_; | |||||||||
| 60 | 0 | ▶ | if( defined($priority) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | setpriority(0, $self->pid, $priority); | |||||||||
| 62 | 0 | ▶ | if( getpriority(0, $self->pid) == $priority ){ # Yuck; getpriority doesn't return a status | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->{priority} = $priority; | |||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | 0 | return $self->{priority}; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub pgrp { | ||||||||
|
Subroutine
pgrp: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 70 | 0 | my ($self, $pgrp) = @_; | |||||||||
| 71 | 0 | ▶ | if( defined($pgrp) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | setpgrp($self->pid, $pgrp); | |||||||||
| 73 | 0 | ▶ | if( getpgrp($self->pid) == $pgrp ){ # Ditto setpgrp | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 {} | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||
| 83 | |||||||||||
| 84 | # Autoload methods go after =cut, and are processed by the autosplit program. | ||||||||||
| 85 | |||||||||||
| 86 | 6 | 1; | |||||||||
| 87 | __END__ | ||||||||||