1ProcessTable(3)       User Contributed Perl Documentation      ProcessTable(3)
2
3
4

NAME

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

SYNOPSIS

9         use Proc::ProcessTable;
10
11         $p = new Proc::ProcessTable( 'cache_ttys' => 1 );
12         @fields = $p->fields;
13         $ref = $p->table;
14

DESCRIPTION

16       Perl interface to the unix process table.
17

METHODS

19       new Creates a new ProcessTable object. The constructor can take one
20           flag:
21
22           cache_ttys -- causes the constructor to look for and use a file
23           that caches a mapping of tty names to device numbers, and to create
24           the file if it doesn't exist (this file is /tmp/TTYDEVS by
25           default). This feature requires the Storable module.
26
27       fields
28           Returns a list of the field names supported by the module on the
29           current architecture.
30
31       table
32           Reads the process table and returns a reference to an array of
33           Proc::ProcessTable::Process objects. Attributes of a process object
34           are returned by accessors named for the attribute; for example, to
35           get the uid of a process just do:
36
37           $process->uid
38
39           The priority and pgrp methods also allow values to be set, since
40           these are supported directly by internal perl functions.
41

EXAMPLES

43        # A cheap and sleazy version of ps
44        use Proc::ProcessTable;
45
46        $FORMAT = "%-6s %-10s %-8s %-24s %s\n";
47        $t = new Proc::ProcessTable;
48        printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND");
49        foreach $p ( @{$t->table} ){
50          printf($FORMAT,
51                 $p->pid,
52                 $p->ttydev,
53                 $p->state,
54                 scalar(localtime($p->start)),
55                 $p->cmndline);
56        }
57
58        # Dump all the information in the current process table
59        use Proc::ProcessTable;
60
61        $t = new Proc::ProcessTable;
62
63        foreach $p (@{$t->table}) {
64         print "--------------------------------\n";
65         foreach $f ($t->fields){
66           print $f, ":  ", $p->{$f}, "\n";
67         }
68        }
69

CAVEATS

71       Please see the file README in the distribution for a list of supported
72       operating systems. Please see the file PORTING for information on how
73       to help make this work on your OS.
74

AUTHOR

76       D. Urist, durist@frii.com
77

SEE ALSO

79       Proc::ProcessTable::Process.pm, perl(1).
80
81
82
83perl v5.8.8                       2006-07-01                   ProcessTable(3)
Impressum