improve pcntl function check

This commit is contained in:
xiaomlove
2023-06-15 21:29:05 +08:00
parent 0036c4ad28
commit ae77dfa0f6
2 changed files with 10 additions and 5 deletions

View File

@@ -97,9 +97,8 @@ class Test extends Command
*/
public function handle()
{
$r = executeCommand("php -m");
$r = preg_split("/[\r\n]+/", $r);
dd($r);
$r = executeCommand("php -r 'var_export(function_exists(\"pcntl_alarm\"));'");
dd($r == 'true');
}
}

View File

@@ -38,7 +38,7 @@ class Install
];
protected array $requiredFunctions = [
'symlink', 'putenv', 'proc_open', 'proc_get_status', 'exec',
// 'pcntl_signal', 'pcntl_alarm', 'pcntl_async_signals'
'pcntl_signal', 'pcntl_alarm', 'pcntl_async_signals'
];
protected string $lockFile = 'install.lock';
@@ -168,7 +168,13 @@ class Install
$disabledFunctions = [];
foreach ($this->requiredFunctions as $fn) {
if (!function_exists($fn)) {
if (str_starts_with($fn, "pcntl_")) {
$phpPath = nexus_env('PHP_PATH') ?: 'php';
$exists = executeCommand("$phpPath -r 'var_export(function_exists(\"$fn\"));'") == 'true';
if (!$exists) {
$disabledFunctions[] = $fn;
}
} elseif (!function_exists($fn)) {
$disabledFunctions[] = $fn;
}
}