public function shareFileDescriptor()
{
$file = fopen($this->mShareFile,"r");
echo "before fork the current offset is:".ftell($file)."\r\n";
$pid = pcntl_fork();
switch ($pid) {
case -1:
echo "something error!\r\n";
break;
case 0:
$childPid = posix_getpid();
fseek($file,5);
echo "in child we modify the offset the current offset is:".ftell($file)."\r\n";
break;
default:
sleep(5);
$content = fread($file,5);
echo "in parent we read :".$content."\r\n";
echo "in parent, child has modified the offset the current offset is:".ftell($file)."\r\n";
break;
}
}