PHP: What does pcntl_fork() really do?

前端 未结 4 1534
执念已碎
执念已碎 2021-01-02 00:37

PHP\'s pcntl_fork function is supposed to fork a process just as the standard fork function in C.
But I was wondering if this function really forks the process or if it

4条回答
  •  借酒劲吻你
    2021-01-02 01:10

    It's not a good idea to run PHP as a module on an Apache installation configured for worker MPM in the first place, because PHP is not threadsafe (I think that is stated somewhere in the PHP manual too).

    It should fork the process, yes. The PHP manual even states that you should read man fork(2) for further instructions, so it's probably just a wrapper around the C fork function.

    Update: Here's the relevant page in the PHP manual for worker MPM: http://php.net/install.unix.apache2.php

    Note: To build a multithreaded version of Apache, the target system must support threads. In this case, PHP should also be built with experimental Zend Thread Safety (ZTS). Under this configuration, not all extensions will be available. The recommended setup is to build Apache with the default prefork MPM-Module.

    I also found this page with some further instructions: http://www.stevekallestad.com/blog/apache_worker_mpm_with_php.html

提交回复
热议问题