-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
从5.0.2版本开始,Process::signal收到不信号回调 #5080
Comments
麻烦提供一下复现代码。 |
<?php
use Swoole\Process;
use Swoole\Coroutine;
echo 'Main Process kill -15 ' . posix_getpid() . "\n" . 'swoole version:' . swoole_version() . "\n";
$pool = new Process\Pool(5);
$pool->set(['enable_coroutine' => true]);
$pool->on('WorkerStart', function (Process\Pool $pool, $workerId) {
/**
* 当前是 Worker 进程
*/
static $running = true;
Process::signal(SIGTERM, function () use (&$running) {
$running = false;
echo "TERM\n";
});
echo "[Worker #{$workerId}] WorkerStart, pid: " . posix_getpid() . "\n";
while ($running) {
Coroutine::sleep(1);
echo 'sleep 1';
}
echo "[Worker #{$workerId}] WorkerStart, pid: " . posix_getpid() . " over\n";
});
$pool->on('WorkerStop', function (\Swoole\Process\Pool $pool, $workerId) {
echo "[Worker #{$workerId}] WorkerStop\n";
});
$pool->start(); |
我没法复现出来,在master分支,V5.0.1版本上,发送 |
5.0.2及之后,是可以结束子进程 |
你看我上面发的图,5.0.1及之前的版本,收到15信号后,是会输出TERM,及进程循环退出时打印的输出 |
buntu 22.04 |
复现出来了,我看看是为啥 |
matyhtf
pushed a commit
that referenced
this issue
Jun 29, 2023
Fixed by #5081 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please answer these questions before submitting your issue.
What did you do? If possible, provide a simple script for reproducing the error.
Process::signal(SIGTERM, function () {
echo '收到退出信号';
$this->pool->getProcess()->exit();
});
What did you expect to see?
从5.0.2版本开始,该注册收不到信号回调,切回5.0.1,或4版本均正常
What did you see instead?
What version of Swoole are you using (show your
php --ri swoole
)?What is your machine environment used (show your
uname -a
&php -v
&gcc -v
) ?Swoole => enabled
Author => Swoole Team team@swoole.com
Version => 5.0.1
Built => Jun 26 2023 16:56:00
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 3.0.2 15 Mar 2022
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
c-ares => 1.18.1
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
coroutine_postgresql => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
The text was updated successfully, but these errors were encountered: