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
59        # Dump all the information in the current process table
60        use Proc::ProcessTable;
61
62        $t = new Proc::ProcessTable;
63
64        foreach $p (@{$t->table}) {
65         print "--------------------------------\n";
66         foreach $f ($t->fields){
67           print $f, ":  ", $p->{$f}, "\n";
68         }
69        }
70

CAVEATS

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

AUTHOR

77       D. Urist, durist@frii.com
78

SEE ALSO

80       Proc::ProcessTable::Process.pm, perl(1).
81
82
83
84perl v5.12.0                      2008-07-25                   ProcessTable(3)
Impressum