php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78717 pcntl_waitpid does not return process PID on child exit when ext-grpc is enabled
Submitted: 2019-10-22 09:36 UTC Modified: 2021-11-15 17:34 UTC
Votes:6
Avg. Score:4.7 ± 0.5
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: simon at podlipsky dot net Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.3.11 OS: MacOS Catalina
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: simon at podlipsky dot net
New email:
PHP Version: OS:

 

 [2019-10-22 09:36 UTC] simon at podlipsky dot net
Description:
------------
pcntl_waitpid() always returns 0 on php 7.3 but on 7.2 it returns PID of exited child.

Example call: `$pid = pcntl_waitpid($procData['pid'], $status, WNOHANG);`

This is script linked below output on php 7.2.23:

```
/usr/local/Cellar/php@7.2/7.2.23/bin/php script.php
Exiting child 0
unset child 0
```

This is the output on php 7.3.10:

```
/usr/local/Cellar/php/7.3.10/bin/php script.php
Exiting child 0
```


On PHP 7.3 the script never ends and is stuck in infinite while loop because `if ($res === $procData['pid'])` expects PID to be assigned in `$res` on child exit but that never happens.

Test script:
---------------
https://gist.github.com/simPod/5a177947bdf864026bfc59d71d6e9d71


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-10-22 09:46 UTC] nikic@php.net
Works for me on Linux, likely MacOS specific.
 [2019-10-22 09:48 UTC] simon at podlipsky dot net
I forgot to specify, sorry. We tested on linux 7.3.10 and it went smoothly. Trying to find another mac with 7.3 installed
 [2019-10-22 10:50 UTC] simon at podlipsky dot net
Tried on another macos catalina and it works there. Not sure what might be wrong on my side though. Trying to investigate.
 [2019-11-10 14:52 UTC] simon at podlipsky dot net
I has something to do with grpc extension. 

`pecl install grpc` should enable the bug
 [2019-11-10 14:55 UTC] simon at podlipsky dot net
-Summary: pcntl_waitpid does not return process PID on child exit +Summary: pcntl_waitpid does not return process PID on child exit when ext-grpc is enabled -PHP Version: 7.3.10 +PHP Version: 7.3.11
 [2019-11-10 14:55 UTC] simon at podlipsky dot net
update title to include grpc
 [2019-12-02 12:32 UTC] antonio at hunos dot net
Same behaviour with php-7.2.24 on Linux 3.16.0-4-amd64 with gRPC-1.25.0
 [2019-12-02 12:58 UTC] simon at podlipsky dot net
I have created issue here https://github.com/grpc/grpc/issues/20994

However, the author doesn't seem to care much about the issue. There's workaround but still it's bug in grpc extension in the first place.
 [2021-11-15 17:34 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: PCNTL related +Package: Unknown/Other Function -Assigned To: +Assigned To: cmb
 [2021-11-15 17:34 UTC] cmb@php.net
I'm afraid there is nothing we can do.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 19:01:29 2024 UTC