original_string: public static function fork($id = 0, callable $childHandler = null)
      {
          $info = [];
          $pid = pcntl_fork();
  
          if ($pid > 0) {// at parent, get forked child info
              $info = [
                  'id' => $id,
                  'pid' => $pid,
                  'startTime' => time(),
              ];
          } elseif ($pid === 0) { // at child
              $pid = getmypid();
  
              if ($childHandler) {
                  $childHandler($id, $pid);
              }
  
          } else {
              Cli::stderr("Fork child process failed! exiting.\n");
          }
  
          return $info;
      }
code: public static function fork($id = 0, callable $childHandler = null)
      {
          $info = [];
          $pid = pcntl_fork();
  
          if ($pid > 0) {// at parent, get forked child info
              $info = [
                  'id' => $id,
                  'pid' => $pid,
                  'startTime' => time(),
              ];
          } elseif ($pid === 0) { // at child
              $pid = getmypid();
  
              if ($childHandler) {
                  $childHandler($id, $pid);
              }
  
          } else {
              Cli::stderr("Fork child process failed! exiting.\n");
          }
  
          return $info;
      }
code_tokens: public static function fork ( $ id = 0 , callable $ childHandler = null ) { $ info = [ ] ; $ pid = pcntl_fork ( ) ; if ( $ pid > 0 ) { // at parent, get forked child info $ info = [ 'id' => $ id , 'pid' => $ pid , 'startTime' => time ( ) , ] ; } elseif ( $ pid === 0 ) { // at child $ pid = getmypid ( ) ; if ( $ childHandler ) { $ childHandler ( $ id , $ pid ) ; } } else { Cli :: stderr ( "Fork child process failed! exiting.\n" ) ; } return $ info ; }
docstring: fork a child process.
  @param int $id
  @param callable|null $childHandler
  param bool $first
  @return array
docstring_tokens: fork a child process .