Example #1
0
 /**
  * Starts the work of the fork
  * 
  * @param integer $pid
  * @param callable $callback
  * @param \Zepi\Core\Utils\Entity\Task $task
  * @param \Zepi\Core\Utils\Entity\Process $oldProcess
  */
 protected function startFork($pid, $callback, Task $task, Process $oldProcess = null)
 {
     if ($pid === -1) {
         $this->cliHelper->writeTimeLine('Could not fork!');
         exit;
     } elseif ($pid) {
         $newProcess = new Process($task, $pid);
         $this->processes[$pid] = $newProcess;
         if ($callback !== null) {
             if ($oldProcess !== null) {
                 call_user_func($callback, $oldProcess, $newProcess);
             } else {
                 call_user_func($callback, $newProcess);
             }
         }
     } else {
         $this->executeTask($task);
     }
 }