测试异步

This commit is contained in:
2025-12-03 10:15:19 +08:00
parent be7dc27d20
commit 05db9b6f02

View File

@@ -863,6 +863,26 @@ class Ceshi extends Controllers
//测试异步信息
public function test_async_info(){
// 创建子进程
$pid = pcntl_fork();
if ($pid == -1) {
die('无法创建子进程');
} elseif ($pid) {
// 父进程
echo "父进程继续执行\n";
// 父进程不等待子进程
} else {
// 子进程
sleep(5);
echo "子进程5秒后执行\n";
exit(0); // 子进程结束
}
echo "父进程继续执行其他代码\n";
}