Symfony\Component\Process\Process::wait PHP Метод

wait() публичный Метод

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.
public wait ( callable $callback = null ) : integer
$callback callable A valid PHP callback
Результат integer The exitcode of the process
    public function wait(callable $callback = null)
    {
        $this->requireProcessIsStarted(__FUNCTION__);
        $this->updateStatus(false);
        if (null !== $callback) {
            if (!$this->processPipes->haveReadSupport()) {
                $this->stop(0);
                throw new \LogicException('Pass the callback to the Process:start method or enableOutput to use a callback with Process::wait');
            }
            $this->callback = $this->buildCallback($callback);
        }
        do {
            $this->checkTimeout();
            $running = '\\' === DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
            $this->readPipes($running, '\\' !== DIRECTORY_SEPARATOR || !$running);
        } 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;
    }

Usage Example

 /**
  * @When /^I run behat$/
  */
 public function iRunBehat()
 {
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"')), '--format=progress'));
     $this->process->start();
     $this->process->wait();
 }
All Usage Examples Of Symfony\Component\Process\Process::wait