Proc::ProcessTable(3)
β¨ NAME β¨
okay so bestie, this is the Proc::ProcessTable(3) page from User Contributed Perl Documentation, and it's literally a Perl extension to access the unix process table. no cap π
πΈ SYNOPSIS πΈ
use Proc::ProcessTable;
my $p = Proc::ProcessTable->new( 'cache_ttys' => 1 );
my @fields = $p->fields;
my $ref = $p->table;
π DESCRIPTION π
It's a Perl interface to the unix process table. iconic behavior honestly β¨
π METHODS π
π new π
Creates a new ProcessTable object. The constructor can take these flags:
enable_ttysβ this makes the constructor use the tty determination code, and that's the default behavior. Setting it to0disables this code, so the module won't traverse the device tree. On some systems that tree 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 you specify this withcache_ttys, a warning is generated andcache_ttysis overridden to be false. πcache_ttysβ this makes the constructor look for and use a file that caches a mapping of tty names to device numbers, and it creates the file if it doesn't exist. This feature requires theStorablemodule. By default, the cache file name consists of a prefix/tmp/TTYDEVS_and a byte order tag. You can access (and change) the file name via$Proc::ProcessTable::TTYDEVSFILE. π
π fields π
Returns a list of the field names supported by the module on the current architecture. lowkey useful for finding out what your vibe check can actually see π¦
π 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:
$process->uid
The priority and pgrp methods also allow values to be set, since these are supported directly by internal perl functions. periodt π₯
π¦ EXAMPLES π¦
First up, a cheap and sleazy version of ps β honestly iconic:
# A cheap and sleazy version of ps
use Proc::ProcessTable;
my $FORMAT = "%-6s %-10s %-8s %-24s %s\n";
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);
}
And this one dumps all the information in the current process table:
# Dump all the information in the current process table
use Proc::ProcessTable;
my $t = Proc::ProcessTable->new;
foreach my $p (@{$t->table}) {
print "--------------------------------\n";
foreach my $f ($t->fields){
print $f, ": ", $p->{$f}, "\n";
}
}
π 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. fr fr, check those files before you come for the module π
π AUTHOR π
J. Bargsten, D. Urist β shoutout to the authors, absolute main characters π«Ά
π SEE ALSO π
Proc::ProcessTable::Processperl(1)
π okay bestie, that's the whole page β from perl v5.42.0, dated 2023-06-22, and it's Proc::ProcessTable(3). stay iconic! π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Proc-ProcessTable 0.636-bp160.1.13 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- opensuse-leap 16.0: perl-Proc-ProcessTable 0.636-bp160.1.13 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- opensuse-leap 16.0: perl-Proc-ProcessTable 0.636-bp160.1.13 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- opensuse-leap 16.0: perl-Proc-ProcessTable 0.636-bp160.1.13 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms