This is automatic generated document for things in Swow\Process\ChildProcess class

Class ChildProcess

Methods

Static method fork

public static function fork ( \Closure $callback ) : self

Fork the current process and run a closure in the child.

POSIX only. Throws ProcessException on Windows.

Throws ProcessException

Static method spawn

public static function spawn ( non-empty-list<string> $command , array{cwd?: string, env?: array<string, string>, stdin?: (inherit | pipe | resource | array{0: file, 1: string, 2?: string}), stdout?: (inherit | pipe | resource | array{0: file, 1: string, 2?: string}), stderr?: (inherit | pipe | resource | array{0: file, 1: string, 2?: string}), fds?: array<int, (resource | int)>} $options ) : self

Spawn a command.

stdio defaults to inherit. A pipe returns a PHP stream; a file redirects to the given path; a resource uses the existing stream. Extra child file descriptors can be passed through fds, with child fd keys in the range 3 to 256.

Throws ProcessException when the command cannot be spawned

Method __destruct

public function __destruct ( )

Close the process object during destruction.

Internal

Method close

public function close ( ) : void

Close the process object.

This never kills the process. Closing a running process abandons it and releases the process handle; the child continues to run. A POSIX child may remain a zombie until the parent exits. Calling close more than once is allowed. After close the object cannot be used for getPid, wait, hasExited, or kill.

Throws ProcessException when another coroutine is waiting

Method getPid

public function getPid ( ) : int

Get the process id.

Method getStderr

public function getStderr ( ) : (resource | null)

Get the parent side of the stderr pipe.

Returns (resource | null) null unless stderr is a pipe

Method getStdin

public function getStdin ( ) : (resource | null)

Get the parent side of the stdin pipe.

Returns (resource | null) null unless stdin is a pipe

Method getStdout

public function getStdout ( ) : (resource | null)

Get the parent side of the stdout pipe.

Returns (resource | null) null unless stdout is a pipe

Method hasExited

public function hasExited ( ) : bool

Check whether the process has exited.

Method kill

public function kill ( int $signal ) : void

Send a signal to the process.

Windows supports SIGINT, SIGBREAK, and SIGKILL. SIGTERM is not supported on Windows.

Throws ProcessException when the signal cannot be sent

Method wait

public function wait ( int $timeout ) : ProcessExitStatus

Wait for the process to exit.

Param int $timeout timeout in milliseconds, -1 means infinite

Throws ProcessException when waiting fails or times out


Copyright 2022 the Swow contributors