WorkerInterface

Interface

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.

Table of Contents

Methods

getErrorOutput()

Returns the captured error output produced by this worker.

 : string
getExitCode()

Returns the worker exit code when it exits normally.

 : int|null
getOutput()

Returns the captured standard output produced by this worker.

 : string
getPid()

Returns the process identifier (PID) of this worker.

 : int
getStatus()

Returns the raw status reported by the operating system, when available.

 : int|null
getTerminationSignal()

Returns the signal that terminated the worker.

 : Signal|null
isRunning()

Indicates whether this worker is still running.

 : bool
kill()

Sends a signal to this worker.

 : void
wait()

Waits until this worker has finished execution.

 : void
Methods

getErrorOutput()

Public

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
string

Description

the captured error output

getExitCode()

Public

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
int|null

Description

the exit code or null if not applicable

getOutput()

Public

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
string

Description

the captured output

getPid()

Public

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
int

Description

the worker process identifier

getStatus()

Public

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
int|null

Description

the raw process status or null if unavailable

getTerminationSignal()

Public

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
Signal|null

Description

the terminating signal or null if not applicable

isRunning()

Public

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
bool

Description

true if the worker is running; otherwise false

kill()

Public

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

wait()

Public

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.