PHP多进程异常终止
public function start(){
echo "Multi-process start\n";
while (true){
$this->parentRun();
echo "当前任务数:" . self::$isfork . "\n";
if(!$this->isFork()){
echo "wait " . $this->waitTime . "s\n";
sleep($this->waitTime);
continue;
}
echo date("Y-m-d h:m:s");
if ( $this->childCount <= $this->max ){
$deploy = array_pop(self::$queue);
$pid=pcntl_fork();
}else{
usleep(10000);
continue;
}
if ($pid == -1) {
die("could not fork");
} else if ($pid) {// we are the parent
echo 'childNum:'.$pid.', maxNum:'.$this->max."\n";
$this->childCount++;
$this->forkMinus();
echo 'childSum:' . $this->childCount."\n";
} else {// we are the child
$this->run($deploy);
exit();
}
}
}
以下代码会异常终止。不知都是什么原因
8158432
11 years, 5 months ago