Skip to main content

\Co\signal

⚠️ This page was initialized by AI translation and may contain outdated or inaccurate information. If there are inaccuracies, please submit changes to correct these errors Correct

API​

namespace Co;

function onSignal(int $signalCode,Closure $closure): string;

Parameter Description​

ParametersTypeDescription
$signalCodeintsignal code
$closureClosureSignal handler, runs in event context

Closure parameters​

ParametersTypeDescription
$signalCodeintsignal 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);
});

Precautions​

After registering any signal handler, if the signal handler is not canceled correctly, \Co\wait will consider that there are unfinished events and will wait until all events are completed.