The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


Proc::ProcessTable - Perl extension to access the unix process table


  use Proc::ProcessTable;

  $p = new Proc::ProcessTable( 'cache_ttys' => 1 ); 
  @fields = $p->fields;
  $ref = $p->table;


Perl interface to the unix process table.



Creates a new ProcessTable object. The constructor can take one flag:

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 file is /tmp/TTYDEVS by default). This feature requires the Storable module.


Returns a list of the field names supported by the module on the current architecture.


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:


The priority and pgrp methods also allow values to be set, since these are supported directly by internal perl functions.


 # A cheap and sleazy version of ps
 use Proc::ProcessTable;

 $FORMAT = "%-6s %-10s %-8s %-24s %s\n";
 $t = new Proc::ProcessTable;
 printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND"); 
 foreach $p ( @{$t->table} ){

 # Dump all the information in the current process table
 use Proc::ProcessTable;

 $t = new Proc::ProcessTable;

 foreach $p (@{$t->table}) {
  print "--------------------------------\n";
  foreach $f ($t->fields){
    print $f, ":  ", $p->{$f}, "\n";


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.


D. Urist,

SEE ALSO, perl(1).