class Subprocess (View source)

Subprocess class.

Constants

STREAM_FILE

Stream STDOUT and/or STDERR to file.

STREAM_STDOUT

Stream STDOUT and/or STDERR to STDOUT.

STREAM_BOTH

Stream STDOUT and/or STDERR to file and STDOUT.

STREAM_STDOUT_WAIT

Stream STDOUT and/or STDERR to STDOUT (wait for process to finish).

STREAM_STDOUT_TTY

Stream STDOUT and/or STDERR to STDOUT (interactive mode).

Methods

array
run(mixed $cmd, boolean $stream = self::STREAM_STDOUT_WAIT, boolean $fail_on_error = false, mixed $stdoutfile = null, mixed $stderrfile = null)

Initiate subprocess.

array
stream_to_file(Process $process, string $stdoutfile, string $stderrfile)

Stream STDOUT and/or STDERR to console.

array
stream_to_stdout(Process $process)

Stream STDOUT and STDERR to console.

array
stream_to_both(Process $process, string $stdoutfile, string $stderrfile)

Stream STDOUT and STDERR to console.

array
stream_stdout_wait(Process $process, boolean $fail_on_error)

Wait for process to finish and return.

array
stream_stdout_tty(Process $process)

Stream STDOUT and STDERR to console (interactive mode).

array
get_process_info(Process $process)

Returns process information.

Details

final array run(mixed $cmd, boolean $stream = self::STREAM_STDOUT_WAIT, boolean $fail_on_error = false, mixed $stdoutfile = null, mixed $stderrfile = null)

Initiate subprocess.

Parameters

mixed $cmd command(s) being executed
boolean $stream whether or not to stream results to console
boolean $fail_on_error whether or not to fail on error or pass
mixed $stdoutfile STDOUT file for output or NULL
mixed $stderrfile STDERR file for output or NULL

Return Value

array STDOUT, STDERR and RETVAL or just RETVAL if streamed

final protected array stream_to_file(Process $process, string $stdoutfile, string $stderrfile)

Stream STDOUT and/or STDERR to console.

Parameters

Process $process process object
string $stdoutfile STDOUT file for output
string $stderrfile STDERR file for output

Return Value

array

final protected array stream_to_stdout(Process $process)

Stream STDOUT and STDERR to console.

Parameters

Process $process process object

Return Value

array

final protected array stream_to_both(Process $process, string $stdoutfile, string $stderrfile)

Stream STDOUT and STDERR to console.

Parameters

Process $process Process object
string $stdoutfile STDOUT file for output
string $stderrfile STDERR file for output

Return Value

array

final protected array stream_stdout_wait(Process $process, boolean $fail_on_error)

Wait for process to finish and return.

Parameters

Process $process process object
boolean $fail_on_error whether or not to fail on error or pass

Return Value

array

final protected array stream_stdout_tty(Process $process)

Stream STDOUT and STDERR to console (interactive mode).

Parameters

Process $process process object

Return Value

array

final protected array get_process_info(Process $process)

Returns process information.

Parameters

Process $process process object

Return Value

array