Why is the use of pcntl library in php is discouraged on prod-serv?

ε祈祈猫儿з 提交于 2019-12-24 09:58:17

问题


Can anybody tell me why using the pcntl lib on production servers is discouraged? The PHP manual tells very briefly about it, and I'm in a dire need to use this library... Is there another way to do the same thing in php?


回答1:


pcntl is discouraged in production environments because the functionality it supports (fork, process control, signal handling) are fairly explicitly things you should not be using in a CGI style application. Now, if you're writing a daemon or command line application in PHP, that is another matter...

From the PHP manual:

Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.




回答2:


one has to be clear about the differences of a php cli script and a sapi/cgi script. php on production systems may as well have support for pcntl.

the important thing here is to have 2 php config files. one for cli and one for cgi setup. one then has to disable pctnl in the cgi setup because the real security issue is, that forking a script when executed by the webserver may leave zombie processes flooding the system.

in a cli environment it might be necessary to be able to write scripts that fork...



来源:https://stackoverflow.com/questions/4899680/why-is-the-use-of-pcntl-library-in-php-is-discouraged-on-prod-serv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!