/usr/lib/perl5/Proc/ProcessTable/Process.pm is in libproc-processtable-perl 0.50-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | package Proc::ProcessTable::Process;
use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD);
require Exporter;
require AutoLoader;
@ISA = qw(Exporter AutoLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw(
);
$VERSION = '0.02';
# Preloaded methods go here.
use Carp;
use File::Basename;
sub AUTOLOAD {
my $self = shift;
my $type = ref($self)
or croak "$self is not an object";
my $name = $AUTOLOAD;
$name =~ s/.*://; # strip fully-qualified portion
unless (exists $self->{$name} ) {
croak "Can't access `$name' field in class $type";
}
if (@_) {
return $self->{$name} = shift;
} else {
return $self->{$name};
}
}
########################################################
# Kill; just a wrapper for perl's kill at the moment
########################################################
sub kill {
my ($self, $signal) = @_;
return( kill($signal, $self->pid) );
}
########################################################
# Get/set accessors for priority and process group
# (everything else is just a get, so handled by autoload)
#########################################################
# Hmmm... These could use the perl functions to get if not stored on the object
sub priority {
my ($self, $priority) = @_;
if( defined($priority) ){
setpriority(0, $self->pid, $priority);
if( getpriority(0, $self->pid) == $priority ){ # Yuck; getpriority doesn't return a status
$self->{priority} = $priority;
}
}
return $self->{priority};
}
sub pgrp {
my ($self, $pgrp) = @_;
if( defined($pgrp) ){
setpgrp($self->pid, $pgrp);
if( getpgrp($self->pid) == $pgrp ){ # Ditto setpgrp
$self->{pgrp} = $pgrp;
}
}
return $self->{pgrp};
}
# Apparently needed for mod_perl
sub DESTROY {}
# Autoload methods go after =cut, and are processed by the autosplit program.
1;
__END__
=head1 NAME
Proc::ProcessTable::Process - Perl process objects
=head1 SYNOPSIS
$process->kill(9);
$process->priority(19);
$process->pgrp(500);
$uid = $process->uid;
...
=head1 DESCRIPTION
This is a stub module to provide OO process attribute access for
Proc::ProcessTable. Proc::ProcessTable::Process objects are
constructed directly by Proc::ProcessTable; there is no constructor
method, only accessors.
=head1 METHODS
=over 4
=item kill
Sends a signal to the process; just an aesthetic wrapper for perl's
kill. Takes the signal (name or number) as an argument. Returns number
of processes signalled.
=item priority
Get/set accessor; if called with a numeric argument, attempts to reset
the process's priority to that number using perl's <B>setpriority
function. Returns the process priority.
=item pgrp
Same as above for the process group.
=item all other methods...
are simple accessors that retrieve the process attributes for which
they are named. Currently supported are:
uid UID of process
gid GID of process
euid effective UID of process (Solaris only)
egid effective GID of process (Solaris only)
pid process ID
ppid parent process ID
spid sprod ID (IRIX only)
pgrp process group
sess session ID
cpuid CPU ID of processor running on (IRIX only)
priority priority of process
ttynum tty number of process
flags flags of process
minflt minor page faults (Linux only)
cminflt child minor page faults (Linux only)
majflt major page faults (Linux only)
cmajflt child major page faults (Linux only)
utime user mode time (1/100s of seconds) (Linux only)
stime kernel mode time (Linux only)
cutime child utime (Linux only)
cstime child stime (Linux only)
time user + system time
ctime child user + system time
timensec user + system nanoseconds part (Solaris only)
ctimensec child user + system nanoseconds (Solaris only)
qtime cumulative cpu time (IRIX only)
size virtual memory size (bytes)
rss resident set size (bytes)
wchan address of current system call
fname file name
start start time (seconds since the epoch)
pctcpu percent cpu used since process started
state state of process
pctmem percent memory
cmndline full command line of process
ttydev path of process's tty
clname scheduling class name (IRIX only)
See the "README.osname" files in the distribution for more
up-to-date information.
=back
=head1 AUTHOR
D. Urist, durist@frii.com
=head1 SEE ALSO
Proc::ProcessTable.pm, perl(1).
=cut
|