Package · thread

Signals & exit codes

A precise, at-a-glance reference for the signals Winter Thread sends and the exit codes a task returns. Signal delivery requires the posix extension.

Signals sent by Thread

Each method targets the thread’s own child process.

Method Signal Catchable? Effect
interrupt() SIGINT yes Interrupt, like Ctrl+C. The task may catch and handle it.
terminate() SIGTERM yes Request a graceful shutdown. Ignored if the task doesn’t handle it.
kill() SIGKILL no Force immediate termination. Cannot be caught, blocked, or ignored.
pause() SIGSTOP no Freeze the process. It stays in the process table (isAlive() is true).
resume() SIGCONT Resume a process previously paused with SIGSTOP.

Every method returns true if the signal was delivered, false if the process isn’t running. See the API reference for full signatures.

Signals sent by Signal

The Signal utility signals an arbitrary PID — it does not verify the PID belongs to your process. Prefer Thread methods for lifecycle control.

Method Signal
Signal::interrupt($pid) SIGINT
Signal::termination($pid) SIGTERM
Signal::close($pid) SIGHUP
Signal::kill($pid) SIGKILL
Signal::isProcessRunning($pid) 0 (probe)

Signal::wait(), interruptAndWait(), terminationAndWait(), and closeAndWait() combine a signal with polling until the process exits or a timeout elapses.

PID reuse

Because the OS reuses PIDs, a raw PID can point at an unrelated process by the time you signal it. Read PID reuse & signals before relying on Signal.

Exit codes

join() returns the child’s exit code. The runner uses two codes of its own:

Code Meaning
0 Task completed — run() returned without throwing.
1 Handled failure — an uncaught exception in run(), an empty or invalid payload, or a shared-memory read failure. The runner writes the reason to stderr.

Codes outside this set come from the OS or PHP itself — for example a PHP fatal error, or a process terminated by a signal — and are surfaced as-is.

join() sentinels are not exit codes

join() also returns null (timeout reached) and -1 (thread was never started). These are return values of join(), not codes the process exited with. Table in the API reference.