System::Process
Manipulate system process as perl object. This is a simple wrapper over ps on *nix systems. For Windows systems - under construction.
use System::Process; my $process_object = pidinfo pid => 5321; if ($process_object) { print $process_object->command(); }
pidinfo(%)
params is hash (pid=>4444) || (file=>'/path/to/pid/file' || pattern => 'my\scool\sname')
returns System::Process::Unit object that supports following methods if pid or file option specified. If pattern option specified - returns arrayref of System::Process objects.
If your ps uax header simillar to my: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND You will get these methods:
Returns %CPU.
Returns TIME.
Returns STAT.
Returns TTY.
Returns USER
Returns %MEM
Returns %RSS
Returns VSZ
Returns COMMAND
Returns START
Returns PID
Anyway, you will get methods named as lowercase header values.
Checks possibility of 'kill' process. Returns 1 if possible
Kills a process with specified signal $process_object->kill(9);
Refreshes data for current pid.
Writes pid to desired file. $process_object->write_pid('/my/pid/path');
Returns true if process alive.
To install System::Process, copy and paste the appropriate command in to your terminal.
cpanm
cpanm System::Process
CPAN shell
perl -MCPAN -e shell install System::Process
For more information on module installation, please visit the detailed CPAN module installation guide.