php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71989 Unable to call the exec function asynchronously
Submitted: 2016-04-08 12:59 UTC Modified: 2016-06-23 18:15 UTC
From: ivan dot shib at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 7.0.5 OS: 4.1.19-boot2docker x86_64 Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 20 = ?
Subscribe to this entry?

 
 [2016-04-08 12:59 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-23 18:15 UTC] dsp@php.net
-Status: Open +Status: Not a bug
 [2016-06-23 18:15 UTC] dsp@php.net
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
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 12:01:29 2024 UTC