Brendan Byrd > P9Y-ProcessTable > P9Y::ProcessTable

Download:
P9Y-ProcessTable-1.06.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 1.06   Source  

NAME ^

P9Y::ProcessTable - Portably access the process table

SYNOPSIS ^

    use P9Y::ProcessTable;
 
    my @process_table = P9Y::ProcessTable->table;
    print $process_table[0]->pid."\n";
 
    my @pids = P9Y::ProcessTable->list;
 
    my $perl_process  = P9Y::ProcessTable->process;
    my $other_process = P9Y::ProcessTable->process($pids[0]);
 
    if ($other_process->has_threads) {
       print "# of Threads: ".$other_process->threads."\n";
       sleep 2;
       $other_process->refresh;
       print "# of Threads: ".$other_process->threads."\n";
    }
 
    # A cheap and sleazy version of ps
    my $FORMAT = "%-6s %-10s %-8s %-24s %s\n";
    printf($FORMAT, "PID", "TTY", "STAT", "START", "COMMAND");
    foreach my $p ( P9Y::ProcessTable->table ) {
       printf($FORMAT,
          $p->pid,
          $p->ttydev,
          $p->state,
          scalar(localtime($p->start)),
          $p->cmdline,
       );
    }
 
    # Dump all the information in the current process table
    foreach my $p ( P9Y::ProcessTable->table ) {
       print "--------------------------------\n";
       foreach my $f (P9Y::ProcessTable->fields) {
          my $has_f = 'has_'.$f;
          print $f, ":  ", $p->$f(), "\n" if ( $p->$has_f() );
       }
    }

DESCRIPTION ^

This interface will portably access the process table, no matter what the OS, and normalize its outputs to work similar across all platforms.

METHODS ^

All methods to this module are actually class-based (objectless) calls. However, the P9Y::ProcessTable::Process returns are actual objects.

fields

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

list

Returns a list of PIDs that are available in the process table. On most systems, this is a less heavy call than table, as it doesn't have to look up the information for every single process.

table

Returns a list of P9Y::ProcessTable::Process objects for all of the processes in the process table. (More information in that module POD.)

process

Returns a P9Y::ProcessTable::Process object for the process specified. If a process isn't specified, it will look up $$ (or its platform equivalent).

P9Y? ^

Portability. You know, like I18N and L10N.

SUPPORTED PLATFORMS ^

Currently, this module supports:

HISTORY ^

This module spawned because Proc::ProcessTable has fallen into bugland for the last 4 years, and many people just want to be able to get a simple PID+cmdline from the process table. While this module offers more than that as a bonus, the goal of this module is to have something that JFW, and continues to JFW.

With that in mind, here my list of what went wrong with Proc::ProcessTable. I have nothing against the authors of that module, but I feel like we should try to learn from our failures and adapt in kind.

CAVEATS / TODO ^

SEE ALSO ^

AVAILABILITY ^

The project homepage is https://github.com/SineSwiper/P9Y-ProcessTable/wiki.

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/P9Y::ProcessTable/.

SUPPORT ^

Internet Relay Chat

You can get live help by using IRC ( Internet Relay Chat ). If you don't know what IRC is, please read this excellent guide: http://en.wikipedia.org/wiki/Internet_Relay_Chat. Please be courteous and patient when talking to us, as we might be busy or sleeping! You can join those networks/channels and get help:

Bugs / Feature Requests

Please report any bugs or feature requests via https://github.com/SineSwiper/P9Y-ProcessTable/issues.

AUTHOR ^

Brendan Byrd <bbyrd@cpan.org>

CONTRIBUTORS ^

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2013 by Brendan Byrd.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
syntax highlighting: