BSD-Process
view release on metacpan or search on metacpan
use Exporter;
use XSLoader;
use base qw(Class::Accessor);
use vars qw($VERSION @ISA @EXPORT_OK);
$VERSION = '0.07';
@ISA = qw(Exporter Class::Accessor);
@EXPORT_OK = (qw(process_info process_list P));
BEGIN {
my %alias = (
process_pid => 'pid',
parent_pid => 'ppid',
process_group_id => 'pgid',
tty_process_group_id => 'tpgid',
process_session_id => 'sid',
job_control_counter => 'jobc',
resident_set_size => 'rssize',
rssize_before_swap => 'swrss',
text_size => 'tsize',
exit_status => 'xstat',
accounting_flags => 'acflag',
percent_cpu => 'pctcpu',
estimated_cpu => 'estcpu',
sleep_time => 'slptime',
time_last_swap => 'swtime',
elapsed_time => 'runtime',
process_flags => 'flag',
nice_priority => 'nice',
process_lock_count => 'lock',
run_queue_index => 'rqindex',
current_cpu => 'oncpu',
last_cpu => 'lastcpu',
wchan_message => 'wmesg',
setlogin_name => 'login',
command_name => 'comm',
process_args => 'args',
terminal_session_id => 'tsid',
effective_user_id => 'uid',
real_user_id => 'ruid',
saved_effective_user_id => 'svuid',
real_group_id => 'rgid',
saved_effective_group_id => 'svgid',
number_of_groups => 'ngroups',
group_list => 'groups',
virtual_size => 'size',
data_size => 'dsize',
stack_size => 'ssize',
start_time => 'start',
children_time => 'childtime',
posix_advisory_lock => 'advlock',
has_controlling_terminal => 'controlt',
is_kernel_thread => 'kthread',
no_loadavg_calc => 'noload',
parent_waiting => 'ppwait',
started_profiling => 'profil',
stopped_profiling => 'stopprof',
id_privs_set => 'sugid',
system_process => 'system',
single_exit_not_wait => 'single_exit',
traced_by_debugger => 'traced',
waited_on_by_other => 'waited',
working_on_exiting => 'wexit',
process_called_exec => 'exec',
kernel_session_flag => 'kiflag',
is_locked => 'locked',
controlling_tty_active => 'isctty',
is_session_leader => 'issleader',
process_status => 'stat',
is_being_forked => 'stat_1',
is_runnable => 'stat_2',
is_sleeping_on_addr => 'stat_3',
is_stopped => 'stat_4',
is_a_zombie => 'stat_5',
is_waiting_on_intr => 'stat_6',
is_blocked => 'stat_7',
old_command_name => 'ocomm',
name_of_lock => 'lockname',
priority_scheduling_class => 'pri_class',
priority_level => 'pri_level',
priority_native => 'pri_native',
priority_user => 'pri_user',
user_time => 'utime',
system_time => 'stime',
total_time => 'time',
max_resident_set_size => 'maxrss',
shared_memory_size => 'ixrss',
unshared_data_size => 'idrss',
unshared_stack_size => 'isrss',
page_reclaims => 'minflt',
page_faults => 'majflt',
number_of_swaps => 'nswap',
block_input_ops => 'inblock',
block_output_ops => 'oublock',
messages_sent => 'msgsnd',
messages_received => 'msgrcv',
signals_received => 'nsignals',
voluntary_context_switch => 'nvcsw',
involuntary_context_switch => 'nivcsw',
process_had_threads => 'hadthreads',
emulation_name => 'emul',
process_jail_id => 'jid',
number_of_threads => 'numthreads',
user_time_ch => 'utime_ch',
system_time_ch => 'stime_ch',
total_time_ch => 'time_ch',
max_resident_set_size_ch => 'maxrss_ch',
shared_memory_size_ch => 'ixrss_ch',
unshared_data_size_ch => 'idrss_ch',
unshared_stack_size_ch => 'isrss_ch',
page_reclaims_ch => 'minflt_ch',
page_faults_ch => 'majflt_ch',
number_of_swaps_ch => 'nswap_ch',
block_input_ops_ch => 'inblock_ch',
block_output_ops_ch => 'oublock_ch',
messages_sent_ch => 'msgsnd_ch',
messages_received_ch => 'msgrcv_ch',
signals_received_ch => 'nsignals_ch',
voluntary_context_switch_ch => 'nvcsw_ch',
involuntary_context_switch_ch => 'nivcsw_ch',
=item start_time, start
Epoch time of the creation of the process. B<F5+>
=item children_time, childtime
Amount of real time used by the children processes (if any) of the
process. B<F5+>
=item process_flags, flag
A bitmap of process flags (decoded in the following methods as 0
or 1).
=item posix_advisory_lock, advlock
Flag indicating whether the process holds a POSIX advisory lock. B<F5+>
=item has_controlling_terminal, controlt
Flag indicating whether the process has a controlling terminal (if
true, the terminal session id is stored in the C<tsid> attribute). B<F5+>
=item is_kernel_thread, kthread
Flag indicating whether the process is a kernel thread. B<F5+>
=item no_loadavg_calc, noload
Flag indicating whether the process contributes to the load average
calculations of the system. B<F5+>
=item parent_waiting, ppwait
Flag indicating whether the parent is waiting for the process to
exit. B<F5+>
=item started_profiling, profil
Flag indicating whether the process has started profiling. B<F5+>
=item stopped_profiling, stopprof
Flag indicating whether the process has a thread that has requesting
profiling to stop. B<F5+>
=item process_had_threads, hadthreads
Flag indicating whether the process has had thresds. B<F6+>
=item id_privs_set, sugid
Flag indicating whether the process has set id privileges since
last exec. B<F5+>
=item system_process, system
Flag indicating whether the process is a system process. B<F5+>
=item single_exit_not_wait, single_exit
Flag indicating that threads that are suspended should exit, not
wait. B<F5+>
=item traced_by_debugger, traced
Flag indicating that the process is being traced by a debugger. B<F5+>
=item waited_on_by_other, waited
Flag indicating that another process is waiting for the process. B<F5+>
=item working_on_exiting, wexit
Flag indicating that the process is working on exiting. B<F5+>
=item process_called_exec, exec
Flag indicating that the process has called exec. B<F5+>
=item kernel_session_flag, kiflag
A bitmap described kernel session status of the process, described
via the following attributes. B<F5+>
=item is_locked, locked
Flag indicating that the process is waiting on a lock (whose name
may be obtained from the C<lock> attribute). B<F5+>
if ($p->is_locked) {
print "$p->{comm} is waiting on lock $p->{lockname}\n";
}
else {
print "not waiting on a lock\n";
}
=item controlling_tty_active, isctty
Flag indicating that the vnode of the controlling tty is active. B<F5+>
=item is_session_leader, issleader
Flag indicating that the process is a session leader. B<F5+>
=item process_status, stat
Numeric value indicating the status of the process, decoded via the
following attibutes. B<F5+>
=item is_being_forked, stat_1
Status indicates that the process is being forked. B<F5+>
=item is_runnable, stat_2
Status indicates the process is runnable. B<F5+>
=item is_sleeping_on_addr, stat_3
( run in 2.533 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )