\Co\signal
###API
namespace Co;
function onSignal(int $signalCode,Closure $closure): string;
Parameter descriptionβ
Parameters | Type | Description |
---|---|---|
$signalCode | int | signal code |
$closure | Closure | Signal handler, runs in event context |
Closure parametersβ
Parameters | Type | Description |
---|---|---|
$signalCode | int | signal code |
Return valueβ
Returns the unique identifier of the event, allowing the event to be canceled using the \Co\cancel method
Overviewβ
Ripple allows you to listen to system signals through the
onSignal
method and execute the specified closure function when the signal is triggered.
Basic usageβ
\Co\onSignal(SIGINT, function () {
echo 'signal received';
exit(0);
});
Notesβ
After registering any signal handler, if the signal handler is not canceled correctly, \Co\wait will think that there are unfinished events and will wait until all events are completed.