Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mautic.corals.io/app/bundles/CoreBundle/ProcessSignal/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mautic.corals.io/app/bundles/CoreBundle/ProcessSignal/ProcessSignalService.php
<?php

declare(strict_types=1);

namespace Mautic\CoreBundle\ProcessSignal;

use Mautic\CoreBundle\ProcessSignal\Exception\SignalCaughtException;

class ProcessSignalService
{
    public const SIGTERM  = 15;
    public const SIGINT   = 2;
    private const SIGNALS = [self::SIGTERM, self::SIGINT];
    private ?int $signal  = null;

    /**
     * @param int[] $signals
     */
    public function registerSignalHandler(callable $beforeCallback = null, array $signals = self::SIGNALS): void
    {
        if (!function_exists('pcntl_signal')) {
            return;
        }

        $handler = function (int $signal) use ($beforeCallback): void {
            if ($beforeCallback) {
                call_user_func($beforeCallback, $signal);
            }

            $this->signal = $signal;
        };

        foreach ($signals as $signal) {
            pcntl_signal($signal, $handler);
        }
    }

    /**
     * @param int[] $signals
     */
    public function restoreSignalHandler(array $signals = self::SIGNALS): void
    {
        if (!function_exists('pcntl_signal')) {
            return;
        }

        foreach ($signals as $signal) {
            pcntl_signal($signal, SIG_DFL);
        }
    }

    public function isSignalCaught(): bool
    {
        if (!function_exists('pcntl_signal_dispatch')) {
            return false;
        }

        pcntl_signal_dispatch();

        return null !== $this->signal;
    }

    /**
     * @throws SignalCaughtException
     */
    public function throwExceptionIfSignalIsCaught(): void
    {
        if (!$this->isSignalCaught()) {
            return;
        }

        throw new SignalCaughtException($this->signal);
    }
}

Spamworldpro Mini