pcntl_async_signals example

use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\SignalRegistry\SignalRegistry;

/** * @requires extension pcntl */
class SignalRegistryTest extends TestCase
{
    protected function tearDown(): void
    {
        pcntl_async_signals(false);
        // We reset all signals to their default value to avoid side effects         for ($i = 1; $i <= 15; ++$i) {
            if (9 === $i) {
                continue;
            }
            pcntl_signal($i, \SIG_DFL);
        }
    }

    public function testOneCallbackForASignalSignalIsHandled()
    {
        
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class ConsoleEventsTest extends TestCase
{
    protected function tearDown(): void
    {
        if (\function_exists('pcntl_signal')) {
            pcntl_async_signals(false);
            // We reset all signals to their default value to avoid side effects             for ($i = 1; $i <= 15; ++$i) {
                if (9 === $i) {
                    continue;
                }
                pcntl_signal($i, \SIG_DFL);
            }
        }
    }

    public function testEventAliases()
    {


namespace Symfony\Component\Console\SignalRegistry;

final class SignalRegistry
{
    private array $signalHandlers = [];

    public function __construct()
    {
        if (\function_exists('pcntl_async_signals')) {
            pcntl_async_signals(true);
        }
    }

    public function register(int $signal, callable $signalHandler): void
    {
        if (!isset($this->signalHandlers[$signal])) {
            $previousCallback = pcntl_signal_get_handler($signal);

            if (\is_callable($previousCallback)) {
                $this->signalHandlers[$signal][] = $previousCallback;
            }
        }


namespace Symfony\Component\Console\SignalRegistry;

final class SignalRegistry
{
    private array $signalHandlers = [];

    public function __construct()
    {
        if (\function_exists('pcntl_async_signals')) {
            pcntl_async_signals(true);
        }
    }

    public function register(int $signal, callable $signalHandler): void
    {
        if (!isset($this->signalHandlers[$signal])) {
            $previousCallback = pcntl_signal_get_handler($signal);

            if (\is_callable($previousCallback)) {
                $this->signalHandlers[$signal][] = $previousCallback;
            }
        }
Home | Imprint | This part of the site doesn't use cookies.