You are here

public function Process::wait in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/process/Process.php \Symfony\Component\Process\Process::wait()

Waits for the process to terminate.

The callback receives the type of output (out or err) and some bytes from the output in real-time while writing the standard input to the process. It allows to have feedback from the independent process during execution.

Parameters

callable|null $callback A valid PHP callback:

Return value

int The exitcode of the process

Throws

RuntimeException When process timed out

RuntimeException When process stopped after receiving signal

LogicException When process is not yet started

1 call to Process::wait()
Process::run in vendor/symfony/process/Process.php
Runs the process.

File

vendor/symfony/process/Process.php, line 340

Class

Process
Process is a thin wrapper around proc_* functions to easily start independent PHP processes.

Namespace

Symfony\Component\Process

Code

public function wait($callback = null) {
  $this
    ->requireProcessIsStarted(__FUNCTION__);
  $this
    ->updateStatus(false);
  if (null !== $callback) {
    $this->callback = $this
      ->buildCallback($callback);
  }
  do {
    $this
      ->checkTimeout();
    $running = '\\' === DIRECTORY_SEPARATOR ? $this
      ->isRunning() : $this->processPipes
      ->areOpen();
    $close = '\\' !== DIRECTORY_SEPARATOR || !$running;
    $this
      ->readPipes(true, $close);
  } while ($running);
  while ($this
    ->isRunning()) {
    usleep(1000);
  }
  if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
    throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  }
  return $this->exitcode;
}