WorkerInterface
Defines the contract for a single worker process.
Description
Implementations MUST represent a process created and managed by a fork manager. A worker SHALL expose its lifecycle state, execution result, and communication channels (output and error output).
Consumers MAY interact with a worker to observe its execution, wait for its completion, or send signals to control its lifecycle.
Implementations SHOULD ensure that state access is safe and consistent across process boundaries.
The key words "MUST", "MUST NOT", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119.
Methods
Returns the captured error output produced by this worker.
Returns the worker exit code when it exits normally.
Returns the captured standard output produced by this worker.
Returns the process identifier (PID) of this worker.
Returns the raw status reported by the operating system, when available.
Returns the signal that terminated the worker.
Indicates whether this worker is still running.
Sends a signal to this worker.
Waits until this worker has finished execution.
Returns the captured error output produced by this worker.
public
getErrorOutput() : string
Description
Implementations MAY return partial error output while the worker is still running. Once the worker has terminated, the returned output SHOULD be complete.
Return values
Description
the captured error output
Returns the worker exit code when it exits normally.
public
getExitCode() : int|null
Description
Implementations MUST return a value between 0 and 255 when the worker terminates normally. If the worker has not exited or was terminated by a signal, null SHALL be returned.
Return values
Description
the exit code or null if not applicable
Returns the captured standard output produced by this worker.
public
getOutput() : string
Description
Implementations MAY return partial output while the worker is still running. Once the worker has terminated, the returned output SHOULD be complete.
Return values
Description
the captured output
Returns the process identifier (PID) of this worker.
public
getPid() : int
Description
The PID MUST uniquely identify the worker process within the operating system.
Return values
Description
the worker process identifier
Returns the raw status reported by the operating system, when available.
public
getStatus() : int|null
Description
Implementations MAY return null if the worker has not yet terminated or if the status is not available.
Return values
Description
the raw process status or null if unavailable
Returns the signal that terminated the worker.
public
getTerminationSignal() : Signal|null
Description
Implementations MUST return the corresponding signal when the worker was terminated by a signal. If the worker exited normally or has not yet terminated, null SHALL be returned.
Return values
Description
the terminating signal or null if not applicable
Indicates whether this worker is still running.
public
isRunning() : bool
Description
Implementations MUST return true while the worker process is active and has not yet terminated.
Return values
Description
true if the worker is running; otherwise false
Sends a signal to this worker.
public
kill([Signal
$signal = Signal::Terminate]) : void
Description
Implementations MUST attempt to deliver the provided signal to the worker process. If the worker is no longer running, the implementation MAY ignore the request.
Parameters
Description
the signal to send to the worker
Waits until this worker has finished execution.
public
wait() : void
Description
Implementations MUST block the caller until the worker process has terminated or has been fully reconciled by the manager.