workerman
workerman copied to clipboard
Fixed issue when child process has signal handlers installed, they where ignored.
Fixed issue with child process having custom handlers. When signal is called with child process PID
, it cancels the sleep but handlers wont be called.
Improved default select with stream_select
error check.
Simple test, commenting pcntl_async_signals
will result sleep
disrupted but handler wont be called.
Same is with Workerman, it waits for stream_select and when signal is called it breaks the select, but handlers wont be called.
<?php
pcntl_async_signals(true);
function sig_handler(int $signal, mixed $siginfo): void
{
var_dump($siginfo);
echo 'Yolo';
fwrite(STDOUT, "Received singal $signal". PHP_EOL);
fwrite(STDERR, "Received singal $signal". PHP_EOL);
fflush(STDOUT);
fflush(STDERR);
}
// pm2 sends SIGINT as quit signal
pcntl_signal(SIGINT, 'sig_handler');
pcntl_signal(SIGTERM, 'sig_handler');
pcntl_signal(SIGUSR1, 'sig_handler');
while (true) {
echo 'sleeping 100'. PHP_EOL;
sleep(100);
echo 'woke up'. PHP_EOL;
posix_kill(posix_getpid(), SIGUSR1);
}
In CLI run command kill -s 15 PID
Oh, sorry about the \t
. Forgot to remove them.