Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Process.php

function Process::stop

Stops the process.

Parameters

int|float $timeout The timeout in seconds:

int|null $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9):

Return value

int|null The exit-code of the process or null if it's not running

4 calls to Process::stop()
Process::checkTimeout in vendor/symfony/process/Process.php
Performs a check between the timeout definition and the time the process started.
Process::wait in vendor/symfony/process/Process.php
Waits for the process to terminate.
Process::waitUntil in vendor/symfony/process/Process.php
Waits until the callback returns true.
Process::__destruct in vendor/symfony/process/Process.php

File

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

Class

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

Namespace

Symfony\Component\Process

Code

public function stop(float $timeout = 10, ?int $signal = null) : ?int {
    $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;
}
RSS feed
Powered by Drupal