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

Breadcrumb

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

function SignalHandler::exitWithLastSignal

Exits the process while communicating that the handled signal was what killed the process

This is different from doing exit(SIGINT), and is also different to a successful exit(0).

This should only be used when you received a signal and then handled it to gracefully shutdown and are now ready to shutdown.

``` $signal = SignalHandler::create([SignalHandler::SIGINT], function (string $signal, SignalHandler $handler) { // do cleanup here..

$handler->exitWithLastSignal(); });

// or...

$signal = SignalHandler::create([SignalHandler::SIGINT]);

while ($doingThings) { if ($signal->isTriggered()) { $signal->exitWithLastSignal(); }

// do more things } ```

Return value

never

See also

https://www.cons.org/cracauer/sigint.html

File

vendor/seld/signal-handler/src/SignalHandler.php, line 325

Class

SignalHandler
SignalHandler and factory

Namespace

Seld\Signal

Code

public function exitWithLastSignal() : void {
    $signal = $this->triggered ?? 'SIGINT';
    $signal = defined($signal) ? constant($signal) : 2;
    if (function_exists('posix_kill') && function_exists('posix_getpid')) {
        pcntl_signal($signal, SIG_DFL);
        posix_kill(posix_getpid(), $signal);
    }
    // just in case posix_kill above could not run
    // not strictly correct but it's the best we can do here
    exit(128 + $signal);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal