PHP pcntl Multi-process learning

Source: Internet
Author: User
Go: PHP pcntl multi-process learning

1, capture the child process exit (listen SIGCHLD signal, and then call the Pcntl_wait function)

DECLARE (Ticks=1);p cntl_signal (SIGCHLD, "Sig_handler"), function Sig_handler ($signo) {    switch ($signo) {        case SIGCHLD:            $status = 0;            $child _id = pcntl_wait ($status);            echo sprintf ("Child exit ID: {$child _id} \ n");            Exit (0);            break;        Default:            echo ' uncaugh signal! ';    }} $pid = Pcntl_fork (), if ($pid >0) {    echo sprintf ("fork Child ID: {$pid} \ n");        while (1) {        sleep (1);    }} else{    echo "Child exit \ n";}

2. Capture child process exit (call pcntl_wai* function directly)

3. Capture sub-process exit (pipeline readable between IO multiplexing monitoring processes)

PHP pcntl Multi-process learning

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.