function EventLoop::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.
File
-
vendor/
revolt/ event-loop/ src/ EventLoop.php, line 211
Class
- EventLoop
- Accessor to allow global access to the event loop.
Namespace
RevoltCode
public static function onSignal(int $signal, \Closure $closure) : string {
return self::getDriver()->onSignal($signal, $closure);
}