function Driver::onSignal
Execute a callback when a signal is received.
Warning: Installing the same signal on different instances of this interface is deemed undefined behavior. Implementations MAY try to detect this, if possible, but are not required to. This is due to technical limitations of the signals being registered globally per process.
Multiple callbacks on the same signal MAY be executed in any order.
The created callback MUST immediately be marked as enabled, but only be activated (i.e. callback can be called) right before the next tick. Callbacks MUST NOT be called in the tick they were enabled.
Parameters
int $signal The signal number to monitor.:
\Closure(string, int):void $closure The callback to execute.:
Return value
string A unique identifier that can be used to cancel, enable or disable the callback.
Throws
UnsupportedFeatureException If signal handling is not supported.
2 methods override Driver::onSignal()
- AbstractDriver::onSignal in vendor/
revolt/ event-loop/ src/ EventLoop/ Internal/ AbstractDriver.php - Execute a callback when a signal is received.
- TracingDriver::onSignal in vendor/
revolt/ event-loop/ src/ EventLoop/ Driver/ TracingDriver.php - Execute a callback when a signal is received.
File
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Driver.php, line 175
Class
- Driver
- The driver MUST run in its own fiber and execute callbacks in a separate fiber. If fibers are reused, the driver needs to call {
Namespace
Revolt\EventLoopCode
public function onSignal(int $signal, \Closure $closure) : string;