protected function _createTimer()
{
$pair = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
$pid = pcntl_fork();
//create a fork
if ($pid == -1) {
die("error: pcntl_fork\r\n");
} elseif ($pid) {
//parent
fclose($pair[0]);
return $pair[1];
//one of the pair will be in the parent
} else {
//child process
fclose($pair[1]);
$parent = $pair[0];
//second of the pair will be in the child
while (true) {
fwrite($parent, '1');
usleep($this->timer * 1000000);
}
}
}