pcntl_signal

Supported Versions: PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8
Installs a signal handler
<?php pcntl_signal(int $signal, callable|int $handler, bool $restart_syscalls = true): bool
<?php         foreach ($previousHandlers as $signal => $handler) {

            if (is_null($handler)) {

                pcntl_signal($signal, SIG_DFL);



                unset($previousHandlers[$signal]);

            }
<?php         pcntl_signal(SIGALRM, function () use ($job, $options) {

            if ($job) {

                $this->markJobAsFailedIfWillExceedMaxAttempts(

                    $job->getConnectionName(), $job, (int) $options->maxTries, $e = $this->timeoutExceededException($job)

                );



                $this->markJobAsFailedIfWillExceedMaxExceptions(

                    $job->getConnectionName(), $job, $e

                );



                $this->markJobAsFailedIfItShouldFailOnTimeout(

                    $job->getConnectionName(), $job, $e

                );



                $this->events->dispatch(new JobTimedOut(

                    $job->getConnectionName(), $job

                ));

            }



            $this->kill(static::EXIT_ERROR, $options);

        }, true);



        pcntl_alarm(

            max($this->timeoutForJob($job, $options), 0)
<?php     {

        pcntl_async_signals(true);



        pcntl_signal(SIGQUIT, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGTERM, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGUSR2, fn () => $this->paused = true);

        pcntl_signal(SIGCONT, fn () => $this->paused = false);
<?php         pcntl_async_signals(true);



        pcntl_signal(SIGQUIT, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGTERM, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGUSR2, fn () => $this->paused = true);

        pcntl_signal(SIGCONT, fn () => $this->paused = false);

    }
<?php         pcntl_signal(SIGQUIT, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGTERM, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGUSR2, fn () => $this->paused = true);

        pcntl_signal(SIGCONT, fn () => $this->paused = false);

    }
<?php         pcntl_signal(SIGQUIT, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGTERM, fn () => $this->shouldQuit = true);

        pcntl_signal(SIGUSR2, fn () => $this->paused = true);

        pcntl_signal(SIGCONT, fn () => $this->paused = false);

    }
<?php             @mkdir($directory, 0777, true);

            if ($realDir = realpath($directory)) {

                pcntl_async_signals(true);

                pcntl_signal(SIGINT, function () use ($realDir) {

                    $fs = new Filesystem();

                    $fs->removeDirectory($realDir);

                    exit(130);

                });

            }

        }
<?php     {

        if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {

            pcntl_async_signals(true);

            pcntl_signal(SIGINT, array($this, 'revertComposerFile'));

            pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));

            pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));

        }
<?php         if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {

            pcntl_async_signals(true);

            pcntl_signal(SIGINT, array($this, 'revertComposerFile'));

            pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));

            pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));

        }
<?php             pcntl_async_signals(true);

            pcntl_signal(SIGINT, array($this, 'revertComposerFile'));

            pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));

            pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));

        }



        $this->file = Factory::getComposerFile();
<?php         if (!$shutdownRegistered) {

            if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {

                pcntl_async_signals(true);

                pcntl_signal(SIGINT, function ($sig) {

                    exit(130);

                });

            }



            $shutdownRegistered = true;
<?php         if ($handleInterruptsUnix) {

            pcntl_async_signals(true);

            $prevHandler = pcntl_signal_get_handler(SIGINT);

            pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {

                $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);

                $runCleanup();



                if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {

                    call_user_func($prevHandler, $sig);

                }



                exit(130);

            });

        }

        if ($handleInterruptsWindows) {

            $windowsHandler = function ($event) use ($runCleanup, $io) {
<?php             $runCleanup();



            if ($handleInterruptsUnix) {

                pcntl_signal(SIGINT, $prevHandler);

            }

            if ($handleInterruptsWindows) {

                sapi_windows_set_ctrl_handler($windowsHandler, false);
<?php         }



        if ($handleInterruptsUnix) {

            pcntl_signal(SIGINT, $prevHandler);

        }

        if ($handleInterruptsWindows) {

            sapi_windows_set_ctrl_handler($windowsHandler, false);
<?php         $this->signals->add($signal, $listener);



        if ($first) {

            \pcntl_signal($signal, array($this->signals, 'call'));

        }

    }