class Process
package digigun.sys.process
Class providing static process utility functions.
Static methods
staticexitWithParent():Void
Ensures that the current process terminates if its parent process dies. Useful for worker/child processes to avoid becoming zombies.
staticfork():Int
Forks the current process. On POSIX, this clones the process. On Windows, this emulates a fork by re-launching the current executable.
Returns:
0 in the child process, PID of child in the parent, or -1 on error.
staticgetAffinity():Int
Retrieves the current CPU affinity mask.
Returns:
The bitmask of allowed cores, or -1 if not available.
staticgetFileResourceLimit():Int
Retrieves the current limit for open file descriptors (POSIX) or CRT file handles (Windows).
Returns:
The current limit, or -1 if not available.
staticgetProcessTree(rootPid:Int = -1):Array<ProcessInfo>
Retrieves a hierarchical process tree starting from the specified root PID. If rootPid is -1, returns the full tree starting from system init/root.
Parameters:
rootPid | The PID to start the tree from. |
|---|
Returns:
A list of root-level processes, each with its children.
staticisRoot():Bool
Checks if the current process is running with root/administrator privileges.
Returns:
True if running as root/admin, false otherwise.
staticlistProcesses():Array<ProcessInfo>
Lists all running processes and their basic telemetry.
Returns:
Array of ProcessInfo objects.
staticsetAffinity(mask:Int):Bool
Sets the CPU affinity mask for the current process. Each bit in the mask represents a CPU core (bit 0 = core 0, bit 1 = core 1, etc).
Parameters:
mask | The bitmask of allowed cores. |
|---|
Returns:
True if successful.
staticsetFileResourceLimit(limit:Int):Int
Sets the limit for open file descriptors (POSIX) or CRT file handles (Windows).
Parameters:
limit | The new limit to set. |
|---|
Returns:
The updated limit if successful, or -1 on error.
staticsetPriority(priority:PriorityClass):Bool
Sets the scheduling priority class for the current process. Note: Realtime priority usually requires root/administrative privileges.
Parameters:
priority | The priority class to set. |
|---|
Returns:
True if successful.