| Current Path : /usr/local/man/man3/ |
| Current File : //usr/local/man/man3/Proc::ProcessTable.3pm |
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Proc::ProcessTable 3"
.TH Proc::ProcessTable 3 "2025-07-28" "perl v5.30.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Proc::ProcessTable \- Perl extension to access the unix process table
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use Proc::ProcessTable;
\&
\& my $p = Proc::ProcessTable\->new( \*(Aqcache_ttys\*(Aq => 1 );
\& my @fields = $p\->fields;
\& my $ref = $p\->table;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Perl interface to the unix process table.
.SH "METHODS"
.IX Header "METHODS"
.IP "new" 4
.IX Item "new"
Creates a new ProcessTable object. The constructor can take the following
flags:
.Sp
enable_ttys \*(-- causes the constructor to use the tty determination code,
which is the default behavior. Setting this to 0 disables this code,
thus preventing the module from traversing the device tree, which on some
systems, can be quite large and/or contain invalid device paths (for example,
Solaris does not clean up invalid device entries when disks are swapped). If
this is specified with cache_ttys, a warning is generated and the cache_ttys
is overridden to be false.
.Sp
cache_ttys \*(-- causes the constructor to look for and use a file that
caches a mapping of tty names to device numbers, and to create the
file if it doesn't exist. This feature requires the Storable module.
By default, the cache file name consists of a prefix \fI/tmp/TTYDEVS_\fR and a
byte order tag. The file name can be accessed (and changed) via
\&\f(CW$Proc::ProcessTable::TTYDEVSFILE\fR.
.IP "fields" 4
.IX Item "fields"
Returns a list of the field names supported by the module on the
current architecture.
.IP "table" 4
.IX Item "table"
Reads the process table and returns a reference to an array of
Proc::ProcessTable::Process objects. Attributes of a process object
are returned by accessors named for the attribute; for example, to get
the uid of a process just do:
.Sp
\&\f(CW$process\fR\->uid
.Sp
The priority and pgrp methods also allow values to be set, since these
are supported directly by internal perl functions.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
.Vb 2
\& # A cheap and sleazy version of ps
\& use Proc::ProcessTable;
\&
\& my $FORMAT = "%\-6s %\-10s %\-8s %\-24s %s\en";
\& my $t = Proc::ProcessTable\->new;
\& printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND");
\& foreach my $p ( @{$t\->table} ){
\& printf($FORMAT,
\& $p\->pid,
\& $p\->ttydev,
\& $p\->state,
\& scalar(localtime($p\->start)),
\& $p\->cmndline);
\& }
\&
\&
\& # Dump all the information in the current process table
\& use Proc::ProcessTable;
\&
\& my $t = Proc::ProcessTable\->new;
\&
\& foreach my $p (@{$t\->table}) {
\& print "\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\en";
\& foreach my $f ($t\->fields){
\& print $f, ": ", $p\->{$f}, "\en";
\& }
\& }
.Ve
.SH "CAVEATS"
.IX Header "CAVEATS"
Please see the file \s-1README\s0 in the distribution for a list of supported
operating systems. Please see the file \s-1PORTING\s0 for information on how
to help make this work on your \s-1OS.\s0
.SH "AUTHOR"
.IX Header "AUTHOR"
J. Bargsten, D. Urist
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Proc::ProcessTable::Process, \fBperl\fR\|(1).