Open
Description
-
Your software version (Screenshot of your startup)
Software Version PHP 8.3.13 Swoole 5.1.4 Laravel 10 -
Detail description about this issue(error/log)
We are running LaravelS Process, which, in turn, has been launching child processes.
As we need to watch falling of these child processes , we set custom handler for SIGCHLD in the parent process.
Child processes could call external programs (cat
, touch
etc). Without SIGCHLD handling in parent process, everything is working good.
But after adding SIGCHLD handler, any program cannot start.
- Some reproducible code blocks and steps
Coroutine::set(['hook_flags' => SWOOLE_HOOK_PROC]);
run(function() {
$this->handleSignals();
})
function handleSignals() {
{
$callback = function() {
$this->close(false);
};
Process::signal(SIGINT, $callback);
Process::signal(SIGTERM, $callback);
Process::signal(SIGCHLD, function ($sig) {
while ($ref = Process::wait(false)) {
$message = match ($ref['pid']) {
$this->child1_process_pid => 'Child process 1 closed',
$this->child2_process_pid => 'Child process 2 closed',
};
$this->close(message: $message);
}
});
}
Calling external program in child process:
$procResult = Process::timeout(5)->run('touch /tmp/test');
//or
$procResult = System::exec('touch /tmp/test');
Estimated result : an external program starts.
Obtained result: Program does not start. We are getting error:
Swoole\Coroutine::exec(): The signal [SIGCHLD] is registered, cannot execute swoole_coroutine_exec