Method
Process::run
Starts $command in the background and returns the object that controls it.
Description#
public static Process::run(
string $command,
array $arguments = [],
?string $cwd = null,
?array $env = null
): ProcessInterfaceNothing goes through a shell: $command is searched for in PATH (or taken as a path when it contains a slash) and the arguments are passed as they are. Works the same on POSIX and Windows; the signals are the difference, see ProcessRunner::sendSignal.
Parameters#
- $command string
- The executable
- $arguments array = []
- The arguments, one element each
- $cwd ?string = null
- The working directory of the child; null: the current one
- $env ?array = null
- The environment of the child, replacing the current one; null: inherit it
Return values#
The running process ProcessInterface
Errors / Exceptions#
| Exception | When |
|---|---|
RuntimeException | If the command is not found or not executable, or cannot be started |
See also#
ProcessInterface::stopEnds the process: SIGTERM, then SIGKILL after one second, and waits up to five seconds in all.