PHP Process Signal Processing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.