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

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

Stops the process.
public stop ( integer | float $timeout = 10, integer $signal = null ) : integer
$timeout integer | float The timeout in seconds
$signal integer A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
Результат integer The exit-code of the process
    public function stop($timeout = 10, $signal = null)
    {
        $timeoutMicro = microtime(true) + $timeout;
        if ($this->isRunning()) {
            // given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here
            $this->doSignal(15, false);
            do {
                usleep(1000);
            } while ($this->isRunning() && microtime(true) < $timeoutMicro);
            if ($this->isRunning()) {
                // Avoid exception here: process is supposed to be running, but it might have stopped just
                // after this line. In any case, let's silently discard the error, we cannot do anything.
                $this->doSignal($signal ?: 9, false);
            }
        }
        if ($this->isRunning()) {
            if (isset($this->fallbackStatus['pid'])) {
                unset($this->fallbackStatus['pid']);
                return $this->stop(0, $signal);
            }
            $this->close();
        }
        return $this->exitcode;
    }

Usage Example

 protected static function stopServer()
 {
     if (!static::$enabled) {
         return;
     }
     self::$server->stop();
 }
All Usage Examples Of Symfony\Component\Process\Process::stop