php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43373 pcntl_fork() causes a fatal error instead of returning -1
Submitted: 2007-11-22 11:57 UTC Modified: 2007-11-27 17:14 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: trot at plotinka dot ru Assigned:
Status: Closed Package: PCNTL related
PHP Version: 5.2.5 OS: Unix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: trot at plotinka dot ru
New email:
PHP Version: OS:

 

 [2007-11-22 11:57 UTC] trot at plotinka dot ru
Description:
------------
untraceable "Fatal error: pcntl_fork(): Error 35"

P.S.: CLI mode.

Reproduce code:
---------------
$pid = pcntl_fork();

Expected result:
----------------
$pid == -1; // true

Actual result:
--------------
Fatal error: pcntl_fork(): Error 35 in ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-23 08:07 UTC] trot at plotinka dot ru
ext/pcntl/pcntl.c line 227

delete:
        if (id == -1) {
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error %d", errno);
        }
 [2007-11-25 17:32 UTC] jani@php.net
Exactly what are you reporting here? What's the bug?

 [2007-11-26 12:46 UTC] trot at plotinka dot ru
Fatal error on failure.

But in manual:
"On failure, a -1 will be returned in the parent's context"

http://php.net/pcntl_fork

thx
 [2007-11-26 23:15 UTC] development at domain51 dot com
I just ran into this issue as well...  I was testing PHP's speed at forking N processes and I hit an issue where the OS wasn't able to fork any more processes.  Instead of getting a -1 response, the code referenced below triggers a fatal error and halts PHP.

In other words, the check on line 227 referenced by trot at plotinka dot ru should be deleted.  "-1" is a valid return value and should not trigger an error any failure is encountered during the fork.
 [2007-11-27 17:14 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC