isTerminated() public method

Checks if the process is terminated.
public isTerminated ( ) : boolean
return boolean true if process is terminated, false otherwise
コード例 #1
0
ファイル: TimeoutWait.php プロジェクト: Elfiggo/dock-cli
 /**
  * {@inheritdoc}
  */
 public function wait(Process $process)
 {
     $start = microtime(true);
     $end = $start + $this->timeout / 1000;
     while (!$process->isTerminated() && microtime(true) < $end) {
         usleep(self::TICK * 1000);
     }
     if ($process->isRunning()) {
         $callback = $this->callback;
         $callback();
     }
     $process->wait();
 }
コード例 #2
0
ファイル: AsyncProcessRunner.php プロジェクト: phpro/grumphp
 /**
  * @return bool
  */
 private function handleProcess(Process $process)
 {
     if ($process->isStarted()) {
         if ($process->isTerminated()) {
             $this->running--;
             return true;
         }
         return false;
     }
     // Only start a new process if we haven't reached the limit yet.
     if ($this->running < $this->config->getProcessAsyncLimit()) {
         $process->start();
         $this->running++;
     }
     return false;
 }
コード例 #3
0
 public function testLockingFunctionality()
 {
     if (!class_exists('AppKernel')) {
         $this->markTestSkipped("This test does only work if a full application is installed (including AppKernel class");
     }
     $commandName = $this->getCommand()->getName();
     $reflector = new \ReflectionClass(\AppKernel::class);
     $appDirectory = dirname($reflector->getFileName());
     // start commands in a separate processes
     $process1 = new Process("php {$appDirectory}/console {$commandName} --env=test");
     $process2 = new Process("php {$appDirectory}/console {$commandName} --env=test");
     $process1->start();
     $process2->start();
     // wait until both processes have terminated
     while (!$process1->isTerminated() || !$process2->isTerminated()) {
         usleep(10);
     }
     $this->assertContains('The command is already running in another process.', $process2->getOutput() . $process1->getOutput());
 }
コード例 #4
0
 /**
  * @param string $command
  * @param OutputInterface $output
  * @param callable|null $callback A valid PHP callback
  */
 protected function basicProcess($command, OutputInterface $output, $callback = null)
 {
     $process = new Process($command);
     $process->setTimeout(600);
     $output->writeln($this->helper->formatSection('Executing', $process->getCommandLine(), 'comment'));
     $process->start();
     $process->wait(function ($type, $buffer) use($output) {
         if (Process::ERR == $type) {
             $output->write($this->helper->formatSection('Error', $buffer, 'error'));
         } else {
             $output->write($this->helper->formatSection('Progress', $buffer, 'comment'));
         }
     });
     if ($process->isTerminated()) {
         $output->writeln($this->helper->formatSection('Finishing', $process->getCommandLine(), 'comment'));
         if (null !== $callback) {
             $callback();
         }
     }
 }
コード例 #5
0
 /**
  * Check if the process has terminated.
  *
  * @return bool
  */
 public function isDoneRunning()
 {
     return $this->process->isTerminated();
 }
コード例 #6
0
ファイル: StartCommand.php プロジェクト: bluzphp/bluzman
 /**
  * @param $address
  * @param $environment
  */
 protected function startServer()
 {
     $publicDir = $this->getApplication()->getWorkingPath() . DS . 'public';
     $shellCommand = $this->getBaseCommand();
     $process = new Process($shellCommand, $publicDir);
     if ($this->getInput()->getOption('background')) {
         $process->disableOutput();
         $process->start();
         $processId = $this->getProcessId();
         $this->getApplication()->getConfig()->setOption('server', ['pid' => $processId, 'address' => $address = 'http://' . $this->getAddress()]);
         $this->getOutput()->writeln($this->info('Server has been started at ' . $address));
     } else {
         while ($process instanceof Process) {
             if (!$process->isStarted()) {
                 $process->start();
                 continue;
             }
             echo $process->getIncrementalOutput();
             echo $process->getIncrementalErrorOutput();
             if (!$process->isRunning() || $process->isTerminated()) {
                 $process = false;
                 $this->getOutput()->writeln("");
                 $this->getOutput()->writeln($this->info('Server has been stopped.'));
             }
             sleep(1);
         }
     }
 }