1.多进程:
for ($i = 0; $i < 2; ++$i ) { $nPID = pcntl_fork(); // 创建子进程 if ($nPID == 0) { // 子进程过程 //**********************// exit(0); // 执行完后退出 } } $n = 0; //父进程等待回收子进程,避免僵尸进程 while ($n < 2) { $nStatus = -1; $nPID = pcntl_wait($nStatus, WNOHANG); if ($nPID > 0) { echo "{$nPID} exit\n"; ++$n; } }
如果多进程请求https链接时,返回false或者ssl connect error
因为https在进行进程之前父进程请求https并进行nss验证,子进程再次验证会因为密钥不同而验证失败
解决办法:
父进程请求放入子进程当中。