Annotation of embedaddon/php/ext/pcntl/tests/pcntl_fork_variation.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>