BSD-Process
view release on metacpan or search on metacpan
@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',
);
# make some shorthand accessors
BSD::Process->mk_ro_accessors( values %alias );
# and map some longhand aliases to them
no strict 'refs';
for my $long (keys %alias) {
*{$long} = *{$alias{$long}};
}
sub attr {
return values(%alias);
}
sub attr_len {
The symbolic name of the gid will be returned if the constructor
had the C<resolve> attribute set. B<F5+>
=item saved_effective_group_id, svgid
The saved effective group id of the process. (purpose?) B<F5+>
=item number_of_groups, ngroups
The number of groups to which the process belongs. B<F5+>
=item group_list, groups
A reference to an array of group ids (gids) to which the process belongs. B<F5+>
=item virtual_size, size
The size (in bytes) of virtual memory occupied by the process. B<F5+>
=item resident_set_size, rssize
The size (in kilobytes) of physical memory occupied by the process.
=item rssize_before_swap, swrss
The resident set size of the process before the last swap.
=item text_size, tsize
Text size (in pages) of the process.
=item data_size, dsize
Data size (in pages) of the process. B<F5+>
=item stack_size, ssize
Stack size (in pages) of the process. B<F5+>
=item exit_status, xstat
Exit status of the process (usually zero).
=item accounting_flags, acflag
Process accounting flags (TODO: decode them).
=item percent_cpu, pctcpu
Percentage of CPU time used by the process (for the duration of
swtime, see below).
=item estimated_cpu, estcpu
Time averaged value of ki_cpticks. (as per the comment in user.h,
purpose?)
=item sleep_time, slptime
Number of seconds since the process was last blocked.
=item time_last_swap, swtime
Number of seconds since the process was last swapped in or out.
=item elapsed_time, runtime
Real time used by the process, in microseconds.
=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
Status indicates the process is sleeping on an address. B<F5+>
=item is_stopped, stat_4
Status indicates the process is stopped, either suspended or in a
debugger. B<F5+>
=item is_a_zombie, stat_5
Status indicates the process is a zombie. It is waiting for its
parent to collect its exit code. B<F5+>
=item is_waiting_on_intr, stat_6
Status indicates the process is waiting for an interrupt. B<F5+>
=item is_blocked, stat_7
Status indicates the process is blocked by a lock. B<F5+>
=item nice_priority, nice
The nice value of the process. The more positive the value, the
nicer the process (that is, the less it seeks to sit on the CPU).
=item process_lock_count, lock
Process lock count. If locked, swapping is prevented.
=item run_queue_index, rqindex
When multiple processes are runnable, the run queue index shows the
order in which the processes will be scheduled to run on the CPU.
=item current_cpu, oncpu
Identifies which CPU the process is running on.
=item last_cpu, lastcpu
Identifies the last CPU on which the process was running.
=item old_command_name, ocomm
The old command name. B<F5+>
=item wchan_message, wmesg
wchan message. (purpose?)
=item setlogin_name, login
Name of the user login process that launched the command.
=item name_of_lock, lockname
Name of the lock that the process is waiting on (if the process is
waiting on a lock). B<F5+>
=item command_name, comm
Name of the command.
=item emulation_name, emul
Name of the emulation. B<F6+>
=item process_jail_id, jid
The process jail identifier B<F6+>
=item number_of_threads, numthreads
Number of threads in the process. B<F6+>
=item priority_scheduling_class, pri_class
=item priority_level, pri_level
=item priority_native, pri_native
=item priority_user, pri_user
The parameters pertaining to the scheduling of the process. B<F6+>
=item user_time, utime
Process resource usage information. The amount of time spent by the
( run in 2.015 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )