public function Process::stop

Stops the process.

Parameters

integer|float $timeout The timeout in seconds:

integer $signal A posix signal to send in case the process has not stop at timeout, default is SIGKILL:

Return value

integer The exit-code of the process

Throws

RuntimeException if the process got signaled

2 calls to Process::stop()
Process::checkTimeout in drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php
Performs a check between the timeout definition and the time the process started.
Process::__destruct in drupal/core/vendor/symfony/process/Symfony/Component/Process/Process.php

File

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

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, $signal = null) {
  $timeoutMicro = (int) $timeout * 1000000.0;
  if ($this
    ->isRunning()) {
    proc_terminate($this->process);
    $time = 0;
    while (1 == $this
      ->isRunning() && $time < $timeoutMicro) {
      $time += 1000;
      usleep(1000);
    }
    if ($this
      ->isRunning() && !$this
      ->isSigchildEnabled()) {
      if (null !== $signal || defined('SIGKILL')) {
        $this
          ->signal($signal ?: SIGKILL);
      }
    }
    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;
}