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
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: ivan dot shib at gmail dot com
New email:
PHP Version: OS:

 

 [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: Sat Apr 27 01:01:30 2024 UTC