marek
marek

Reputation: 279

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

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?

Upvotes: 1

Views: 4161

Answers (2)

glasz
glasz

Reputation: 2565

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

Upvotes: 1

Edward Z. Yang
Edward Z. Yang

Reputation: 26742

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.

Upvotes: 3

Related Questions