public function Process::stop

Stops the process.

Parameters

float $timeout The timeout in seconds:

Return value

integer The exitcode of the process

Throws

\RuntimeException if the process got signaled

1 call to Process::stop()

File

drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php, line 551

Class

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

Namespace

Symfony\Component\Process

Code

public function stop($timeout = 10) {
  $timeoutMicro = (int) $timeout * 10000000.0;
  if ($this
    ->isRunning()) {
    proc_terminate($this->process);
    $time = 0;
    while (1 == $this
      ->isRunning() && $time < $timeoutMicro) {
      $time += 1000;
      usleep(1000);
    }
    foreach ($this->pipes as $pipe) {
      fclose($pipe);
    }
    $this->pipes = array();
    $exitcode = proc_close($this->process);
    $this->exitcode = -1 === $this->processInformation['exitcode'] ? $exitcode : $this->processInformation['exitcode'];
    if (defined('PHP_WINDOWS_VERSION_BUILD')) {
      foreach ($this->fileHandles as $fileHandle) {
        fclose($fileHandle);
      }
      $this->fileHandles = array();
    }
  }
  $this->status = self::STATUS_TERMINATED;
  return $this->exitcode;
}