php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81195 pcntl_fork() cause child process hungup.
Submitted: 2021-06-23 08:09 UTC Modified: 2021-06-23 08:44 UTC
Votes:6
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:4 (66.7%)
From: jedemon at gmail dot com Assigned:
Status: Open Package: PCNTL related
PHP Version: 7.4.20 OS: CentOS7 and Ubuntu16
Private report: No CVE-ID: None
 [2021-06-23 08:09 UTC] jedemon at gmail dot com
Description:
------------
From php7.4.11 to php7.4.20, when execute pcntl_fork(), the forked child process will not terminate. 

Execute this line:

php -r "\pcntl_fork(); if(posix_getpid()){pcntl_wait(\$st);} echo 'exit'.PHP_EOL;"
and shell will hung.

This dose not happen in under PHP7.4.10, nor in above PHP8.0+. Tested on Centos7 and Ubuntu16.04.

There is no related info I can find out.

Test script:
---------------
php -r "\pcntl_fork(); if(posix_getpid()){pcntl_wait(\$st);} echo 'exit'.PHP_EOL;"

Expected result:
----------------
exit
exit


Actual result:
--------------
exit

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-23 08:44 UTC] requinix@php.net
I can't reproduce on Ubuntu 18.04.

If pcntl_wait is indeed waiting then that means the process has a child, and I don't see how your -r code could create a third (grand)child process. While it hangs, how many "php" processes are running on the system?
 [2021-07-15 08:47 UTC] martijn at squeezely dot tech
got the same issue on following system:

cat /etc/issue
Ubuntu 20.04.2 LTS \n \l

php -v
PHP 7.4.21 (cli) (built: Jul  1 2021 16:09:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
    with blackfire v1.62.0~linux-x64-non_zts74, https://blackfire.io, by Blackfire
 [2021-07-27 15:07 UTC] martijn at squeezely dot tech
It ended up being the grpc module, when this was disabled it works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 04:01:31 2024 UTC