php pcntl 多进程学习
生活随笔
收集整理的這篇文章主要介紹了
php pcntl 多进程学习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
1、捕獲子進程退出(監聽SIGCHLD信號,然后調用 pcntl_wait 函數)
declare(ticks=1);pcntl_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、捕獲子進程退出(直接調用 pcntl_wai* 函數)
3、捕獲子進程退出 (io復用監控進程間的管道可讀)
?
轉載于:https://www.cnblogs.com/siqi/p/4475080.html
總結
以上是生活随笔為你收集整理的php pcntl 多进程学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于NextCloud,挂载Aria2+
- 下一篇: C# MVC的博客开发(三)注册