ePages 6.17.39 - DE_EPAGES/Core/API/Process.pm

Package DE_EPAGES::Core::API::Process

API functions for working with processes

@EXPORT_OK
GetProcessMemory
GetProcessStat
GetCurrentProcessID
SetProcessPriority
PurgeBackgroundProcesses
WaitForBackgroundProcesses
ShowBackgroundProcesses
RunningProcessExists

Functions

GetCurrentProcessID
GetProcessMemory
GetProcessStat
PurgeBackgroundProcesses
RunningProcessExists
SetProcessPriority
ShowBackgroundProcesses
WaitForBackgroundProcesses

GetCurrentProcessID

Returns the process id of the current process.

Syntax
$ProcessID = GetCurrentProcessID();
Return
$ProcessID (integer)
process id

GetProcessMemory

Returns the amount of memory used by a process.

Syntax
$MemSize = GetProcessMemory( $ProcessID );
Example
print GetProcessMemory( GetCurrentProcessID() ) . " bytes used by this process";
Input
$ProcessID (integer)
process id
Return
$MemSize (integer)
amount of memory used in bytes

GetProcessStat

Returns information retrieved from /proc/<PID>/stat as hash.

Syntax
$hStat = GetProcessStat( $ProcessID );
Input
$ProcessID (integer)
process id
Return
$hStat (ref.hash)
hash with process information from /proc/<PID>/stat
as 'man proc' shows; exceptions:
rss : is returned in bytes, not pages
comm: is returned w/o parenthesis ()

PurgeBackgroundProcesses

Checks if process created by Proc::Background->new() are still alive. Processes older than $Timeout seconds are killed. The returned $aProcesses list does not contain dead processes.

Syntax
$aProcesses = PurgeBackgroundProcesses($aProcessList, $ProcessParam)
Example
PurgeBackgroundProcesses([Proc::Background->new("sleep 5")])
Input
$aProcessList (ref.array.object)
list of process objects (Proc::Background)
$hProcessParam (ref.hash)
parameters
  • timeout - kill processes older than ... seconds - Integer

Return
$aProcesses (ref.array.object)
list of process objects (Proc::Background)

RunningProcessExists

Returns true if the process with giving process id exists.

Syntax
$IsRunning = RunningProcessExists($ProcessID);
Input
$ProcessID (integer)
process id
Return
$ProcessRunning (boolean)
true if process is running

SetProcessPriority

Sets the Priority of a process.

Syntax
SetProcessPriority( $ProcessID, $Priority )
Example
SetProcessPriority( GetCurrentProcessID(), 'ABOVE_NORMAL' );
Input
$ProcessID (integer)
process id
$Priority
priority class, valid values are:
- REALTIME (not recommended for Windows, nice: -20)
- HIGH (same as REALTIME for UNIX, nice: -20)
- ABOVE_NORMAL (aka. ABOVENORMAL, nice: -10)
- NORMAL (nice: 0)
- BELOW_NORMAL (aka. BELOWNORMAL, nice: 10)
- LOW (aka. IDLE, nice: 19)

ShowBackgroundProcesses

Shows processes in $ProcessList created by Proc::Background->new().

Syntax
ShowBackgroundProcesses($ProcessList, $StartTime)
Example
ShowBackgroundProcesses([Proc::Background->new("sleep 5")], time)
Input
$ProcessList (ref. array)
list of process objects
$StartTime (time)
start time
Return
$Result (integer)
0 -> no process alive, 1 -> at least 1 process alive

WaitForBackgroundProcesses

Waits until processes in $ProcessList created by Proc::Background->new() have finished.

Syntax
WaitForBackgroundProcesses($ProcessList, $ProcessParam)
Example
WaitForBackgroundProcesses([Proc::Background->new("sleep 5")])
Input
$ProcessList (ref. array)
list of process objects
$ProcessParam (ref.hash)
parameters
  • timeout - kill processes older than ... seconds - Integer
  • parallel - returns if
Return
$ProcessList (ref. array)
list of parallel process objects (if parameter parallel is set)