Class \Prado\Util\Helpers\TProcessHelper
This class handles process related functions.
self::isSystemWindows() is used to determine if the PHP system is Windows or not.
self::isForkable() can be used if the system supports forking of the current
process. self::fork() is used to fork the current process, where supported.
When forking, fxPrepareForFork
self::FX_PREPARE_FOR_FORK is raised before
forking and fxRestoreAfterFork
self::FX_RESTORE_AFTER_FORK is raised after
forking. When $captureForkLog (fork parameter) is true, a TCaptureForkLog
behavior is attached to the TApplication object. All forked child
processes ensure the TSignalsDispatcher behavior is attached
to the TApplication object to allow for graceful termination on exiting signals.
When filtering commands for popen and proc_open, self::filterCommand() will replace '@php' with PHP_BINARY and wrap Windows commands with double quotes. Individual arguments can be properly shell escaped with self::escapeShellArg().
Linux Process signals can be sent with self::sendSignal() to the current pid or child pid. To kill a child pid, call self::kill(). self::isRunning can determine if a child process is still running.
System Process priority can be retrieved and set with self::getProcessPriority() and self::setProcessPriority(), respectively.
Class hierarchy
Author: Brad Anderson <belisoful@icloud.com>Since: 4.3.0
public
static
|
|
public
static
|
|
public
static
|
filterCommand(mixed $command) : mixed
Filters a {@see popen} or {@see proc_open} command.
The string "@php" is replaced by PHP_BINARY and in Windows the string is surrounded by double quotes. |
public
static
|
fork([bool $captureForkLog = false ]) : int
This forks the current process. When specified, it will install a {@see \Prado\Util\Behaviors\TCaptureForkLog}.
Before forking,
|
public
static
|
|
public
static
|
|
public
static
|
|
public
static
|
isSurroundedBy(string $string, string $prefix) : bool
Is the string surrounded by the prefix and reversed in appendix.
|
public
static
|
|
public
static
|
|
public
static
|
|
public
static
|
|
public
static
|
sendSignal(int $signal[, int|null $pid = null ]) : bool
Sends a process signal on posix or linux systems.
|
public
static
|
setProcessPriority(int $priority[, int|null $pid = null ]) : bool
In linux systems, the priority can only go up (and have less priority).
|
|
public
string
|
FX_PREPARE_FOR_FORK
|
'fxPrepareForFork'
|
public
string
|
FX_RESTORE_AFTER_FORK
|
'fxRestoreAfterFork'
|
public
string
|
PHP_COMMAND
|
"@php"
|
public
mixed
|
WINDOWS_ABOVE_NORMAL_PRIORITY
|
-5
|
public
mixed
|
WINDOWS_BELOW_NORMAL_PRIORITY
|
8
|
public
mixed
|
WINDOWS_HIGH_PRIORITY
|
-10
|
public
mixed
|
WINDOWS_IDLE_PRIORITY
Linux priority is -20 (for "real time") to 19 (for idle).
|
19
|
public
mixed
|
WINDOWS_NORMAL_PRIORITY
|
0
|
public
mixed
|
WINDOWS_REALTIME_PRIORITY
|
-17
|