1--TEST-- 2Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father cannot know his grandson 3--CREDITS-- 4Marco Fabbri mrfabbri@gmail.com 5Francesco Fullone ff@ideato.it 6#PHPTestFest Cesena Italia on 2009-06-20 7--EXTENSIONS-- 8pcntl 9posix 10--FILE-- 11<?php 12echo "*** Testing the process isolations between a process and its forks ***\n"; 13 14$pid = pcntl_fork(); 15 16if ($pid > 0) { 17 pcntl_wait($status); 18 echo "father is $pid\n"; 19 20 if (!isset($pid2)) 21 { 22 echo "father ($pid) doesn't know its grandsons\n"; 23 } 24} 25else 26{ 27 echo "son ($pid)\n"; 28 $pid2 = pcntl_fork(); 29 if ($pid2 > 0) 30 { 31 pcntl_wait($status2); 32 echo "son is father of $pid2\n"; 33 } 34 else 35 { 36 echo "grandson ($pid2)\n"; 37 } 38} 39?> 40--EXPECTF-- 41*** Testing the process isolations between a process and its forks *** 42son (0) 43grandson (0) 44son is father of %d 45father is %d 46father (%d) doesn't know its grandsons 47