php - Handle process signals in Swoole script without pcntl_signal() function

I'm implementing a php parallel tasks script based on Swoole module which works as daemon.
Is it possible to use Swoole functions to handle process signals instead of pcntl_signal()?
<?php
declare(strict_types=1);
declare(ticks=1);
use Swoole\Coroutine as Co;
$stopCommand = false;
$sigHandler = static function (int $sig) use (&$stopCommand)
{
switch ($sig) {
case SIGTERM:
$stopCommand = true;
break;
}
};
pcntl_signal(SIGTERM, $sigHandler);
Co\run(function() use (&$stopCommand) {
$results = [];
while(true) {
//go(static function () use (&$results, &$stopCommand) {}
co::sleep(1);
if(!$results && $stopCommand) {
break;
}
}
});
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: uncaught mysqli_sql_exception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.