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?
Why is the use of pcntl library in php is discouraged on prod-serv?
4k Views Asked by marek At
2
There are 2 best solutions below
1

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...
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: