PHP's PCNTL extension provides the function of signal processing, which allows PHP to take over the processing of signals, and signal processing is critical in the development of server-side daemon processes. Pcntl This extension is only available in cli/cgi mode. Not available in mod_php and PHP-FPM. PHP did not connect the pcntl to the PHP-CLI executable in the process of compiling it.
Function Prototypes:
BOOL pcntl_signal(int $signo, callback $handler [, BOOL $restart _syscalls=true])
The first parameter is the signal ID, which can be found here http://swoole.sinaapp.com/archives/124
The second parameter is the PHP function of the callback when the signal occurs.
The third parameter is whether the restart is re-registered for this signal. If this parameter is false, then this signal is only registered for processing once.
<?phpSignal processing requires registration ticks to take effect, it is important to notePHP5.4 and above are no longer dependent on ticks.DECLARE (Ticks=1);functionSig_handler ($Signo) {Switch ($Signo) {CaseSIGUSR1:echo "sigusr1\n"; case sigusr2:echo " Sigusr2\n "; break;default:echo pcntl_signal (SIGUSR1, "Sig_handler"); Span class= "function call" >pcntl_signal (SIGUSR2, "Sig_handler"); posix_kill (posix_getpid (), SIGUSR1); Span class= "function call" >posix_kill (posix_getpid (), SIGUSR2) ; ?>
PHP Process Signal Processing