标签:php parallel-processing nonblocking
如何在PHP中运行非阻塞系统调用?
系统调用将调用由第二个PHP脚本运行的流服务..所以我的页面坐下来等待这个调用.
我对解决方案的两点看法:
1:存在通过非阻塞执行系统调用的本机方法/参数
2:在一个新的C程序上运行system(),然后在一个sep上自行分叉并运行实际的php脚本.线
是否存在以非阻塞方式执行系统调用的本机方法,或者我是否需要破解此问题…
我目前有shell_exec(‘nohup php /path/to/file.php&’)但它仍然有效
解决方法:
从PHP manual开始:
If a program is started with this function, in order for it to
continue running in the background, the output of the program must be
redirected to a file or another output stream. Failing to do so will
cause PHP to hang until the execution of the program ends.
在同一页面上的注释中提供了一个示例(基于Linux):
If you want to start a php process that continues to run independently
from apache (with a different parent pid) use nohub. Example:exec(‘nohup php process.php > process.out 2> process.err < /dev/null
&’);
标签:php,parallel-processing,nonblocking 来源: https://codeday.me/bug/20190626/1294369.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。