$iterations]; do { $minDepth += 2; if ($minDepth <= $maxDepth) { $iterations >>= 2; $depthIterations[$minDepth] = $iterations; } } while ($minDepth <= $maxDepth); $size = 128; $shmId = shmop_open(ftok(__FILE__, 'b'), 'c', 0644, $size * (count($depthIterations) + 1)); $PIDs = []; $n = 0; foreach ($depthIterations as $d => $i) { $PIDs[] = startWorker($d, $i, ++$n, $size, $shmId); } foreach ($PIDs as $PID) { pcntl_waitpid($PID, $status); } foreach (range(1, count($depthIterations)) as $n) { echo trim(shmop_read($shmId, $size * ($n - 1), $size)), PHP_EOL; } shmop_delete($shmId); echo "long lived tree of depth $maxDepth\t check: ", checkTree($longLivedTree), PHP_EOL; }