Пример #1
0
 /**
  * @expectedException Arara\Process\Exception\RuntimeException
  * @expectedExceptionMessage Unable to fork process
  */
 public function testShouldThrowsAnExceptionWhenForkFails()
 {
     $this->overwrite('pcntl_fork', function () {
         return -1;
     });
     $control = new Control();
     $control->fork();
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function start()
 {
     if ($this->hasId() && $this->isRunning()) {
         throw new RuntimeException('Process already started');
     }
     $this->context->processId = $this->control->fork();
     $this->context->isRunning = true;
     if ($this->context->processId > 0) {
         $this->action->trigger(Action::EVENT_FORK, $this->control, $this->context);
         return;
     }
     $this->context->processId = $this->control->info()->getId();
     $this->context->startTime = time();
     $this->setHandlerAlarm();
     $this->setHandlerErrorException();
     $this->run();
     restore_error_handler();
     $this->control->quit($this->context->exitCode);
 }