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: 2019-11-10 14:55 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: simon at podlipsky dot net Assigned:
Status: Open Package: PCNTL related
PHP Version: 7.3.11 OS: MacOS Catalina
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Sep 23 17:01:24 2020 UTC