.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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 2023-08-09 "perl v5.38.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 README in the distribution for a list of supported operating systems. Please see the file PORTING for information on how to help make this work on your OS. .SH AUTHOR .IX Header "AUTHOR" J. Bargsten, D. Urist .SH "SEE ALSO" .IX Header "SEE ALSO" Proc::ProcessTable::Process, \fBperl\fR\|(1).