Bug #71989 [Opn->Nab]: Unable to call the exec function asynchronously
| From: | dsp@php.net | Date: | Thu, 23 Jun 2016 18:15:14 +0000 |
| Subject: | Bug #71989 [Opn->Nab]: Unable to call the exec function asynchronously | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201812@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71989&edit=1
ID: 71989
Updated by: dsp@php.net
Reported by: ivan dot shib at gmail dot com
Summary: Unable to call the exec function asynchronously
-Status: Open
+Status: Not a bug
Type: Bug
Package: Output Control
Operating System: 4.1.19-boot2docker x86_64 Linux
PHP Version: 7.0.5
Block user comment: N
Private report: N
New Comment:
This is not an error. You are a creating a child process inside the shell without correctly handling
it using waitpid. Therefore the FPM module finds an unknown child and writes this warning. The
correct way to do this is using something along the line of:
$p = pcntl_fork();
if ($p == 0) {
// child process
exec('php -f index.php');
} else if ($p > 0) {
// parent
waitpid($p, $status);
} else {
// error
}
Previous Comments:
------------------------------------------------------------------------
[2016-04-08 12:59:46] ivan dot shib at gmail dot com
Description:
------------
In the php code run the following command:
exec('php -f '.escapeshellarg(ROOT_DIR.'/index.php').' > /dev/null
2>&1 &');
Got the following record in the logs:
2016-04-08T12:55:38.201816261Z [08-Apr-2016 12:55:38] ALERT: oops, unknown child (16) exited with
code 0. Please open a bug report (https://bugs.php.net).
If we remove ' > /dev/null 2>&1 &' part from code then it works fine but not
asynchronously.
Please note that in PHP v 7.0.3 the code above worked fine.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71989&edit=1