public static function defaultSigchldCbk($fd, $events, $args) { $status = ''; while (($pid = \pcntl_waitpid(-1, $status)) > 0) { foreach (self::$child as $key => $value) { if ($value == $pid) { unset(self::$child[$key]); foreach (self::$alias as $key => $value) { if ($pid == $value) { unset(self::$alias[$key]); } } } } Msgqueue::delQueue($pid); } if (count(self::$child) == 0) { exit; } }
public function sig_child($fd, $events, $args) { $status = -1; date_default_timezone_set('Asia/Shanghai'); while (($pid = \pcntl_waitpid(-1, $status, WNOHANG)) > 0) { foreach (Process::$child as $key => $value) { if ($value == $pid) { unset(Process::$child[$key]); foreach (Process::$alias as $key => $value) { if ($pid == $value) { unset(Process::$alias[$key]); } } } } Msgqueue::delQueue($pid); $log_file = Flight::conf()->get('cli.sys.rpc_logpath') . date('Y-m-d') . '.log'; $spare_time = microtime(1) - $this->_spare_time[$pid]; $spare_time = sprintf("%.2f", $spare_time); if (pcntl_wifexited($status)) { $exit_code = pcntl_wexitstatus($status); $log = date("H:i:s") . " exit({$exit_code}-{$pid}):" . json_encode($this->_runing_list[$pid]) . " {$spare_time}"; } else { $exit_code = -1; $log = date("H:i:s") . " exit({$exit_code}-{$pid}):" . json_encode($this->_runing_list[$pid]) . " {$spare_time}"; } $ret = `echo "{$log}" >> {$log_file}`; unset($this->_runing_list[$pid]); unset($this->_spare_time[$pid]); $this->handle(); } }