pcntl_signal

Supported Versions: PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8
Installs a signal handler
pcntl_signal(int $signal, callable|int $handlerbool $restart_syscalls true): bool
        pcntl_signal(SIGALRM, function () use ($job$options) {

            if (
$job) {

                
$this->markJobAsFailedIfWillExceedMaxAttempts(

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

                );



                
$this->markJobAsFailedIfWillExceedMaxExceptions(

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

                
);



                
$this->markJobAsFailedIfItShouldFailOnTimeout(

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

                
);

            }



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

        });



        
pcntl_alarm(

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

        
pcntl_async_signals(true);



        
pcntl_signal(SIGTERM, function () {

            
$this->shouldQuit true;

        });



        
pcntl_signal(SIGUSR2, function () {

            
$this->paused true;
            $this->shouldQuit true;

        });



        
pcntl_signal(SIGUSR2, function () {

            
$this->paused true;

        });



        
pcntl_signal(SIGCONT, function () {

            
$this->paused false;
            $this->paused true;

        });



        
pcntl_signal(SIGCONT, function () {

            
$this->paused false;

        });

    }
            @mkdir($directory0777true);

            if (
$realDir realpath($directory)) {

                
pcntl_async_signals(true);

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

                    
$fs = new Filesystem();

                    
$fs->removeDirectory($realDir);

                    exit(
130);

                });

            }

        }
    {

        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'));

        }
        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'));

        }
            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();
        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;
        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'trueIOInterface::DEBUG);

                
$runCleanup();



                if (!
in_array($prevHandler, array(SIG_DFLSIG_IGN), true)) {

                    
call_user_func($prevHandler$sig);

                }



                exit(
130);

            });

        }

        if (
$handleInterruptsWindows) {

            
$windowsHandler = function ($event) use ($runCleanup$io) {
            $runCleanup();



            if (
$handleInterruptsUnix) {

                
pcntl_signal(SIGINT$prevHandler);

            }

            if (
$handleInterruptsWindows) {

                
sapi_windows_set_ctrl_handler($windowsHandlerfalse);
        }



        if (
$handleInterruptsUnix) {

            
pcntl_signal(SIGINT$prevHandler);

        }

        if (
$handleInterruptsWindows) {

            
sapi_windows_set_ctrl_handler($windowsHandlerfalse);
        $this->signals->add($signal$listener);



        if (
$first) {

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

        }

    }
        $this->signals->remove($signal$listener);



        if (
$this->signals->count($signal) === 0) {

            
\pcntl_signal($signal\SIG_DFL);

        }

    }
        });



        
$handled false;

        
$this->assertTrue(pcntl_signal(constant($signal), function () use (&$handled) {

            
$handled true;

        }));




        
$this->forkSendSignal($signal);