Imnotapotato
Imnotapotato

Reputation: 5828

Updated Ubuntu and pcntl_fork stopped working (php)

Things that changed recently on my server:

I usually run API queries from my PHP code using forking, and in some point it stopped working for me (it does work, but when getting to heavy query results it stopps).

error.log:

[Sun Aug 28 12:15:03.201994 2016] [:notice] [pid 1882] FastCGI: process manager initialized (pid 1882)
[Sun Aug 28 12:15:03.278176 2016] [mpm_prefork:notice] [pid 1879] AH00163: Apache/2.4.18 (Ubuntu) mod_fastcgi/mod_fastcgi-SNAP-0910052141 configured -- resuming normal operations

running cat /var/mail/root outputs:

From root@banana  Sun Aug 28 12:39:01 2016
Return-Path: <root@banana>
X-Original-To: root
Delivered-To: root@banana
Received: by banana (Postfix, from userid 0)
        id ABC281005BA; Sun, 28 Aug 2016 12:39:01 +0300 (IDT)
From: root@banana (Cron Daemon)
To: root@banana
Subject: Cron <root@banana>   [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20160828093901.ABC281005BA@YHserver>
Date: Sun, 28 Aug 2016 12:39:01 +0300 (IDT)

Can someone help me debug the problem better and solve it?

Running this script gets true results:

 <?php
    echo "Is fork? <br/>";
    var_dump (extension_loaded('pcntl'));




echo "<br><br> more checks: <br>";
$supports = array();
if (function_exists("pcntl_fork")) $supports[] = "ispcntl";
echo implode(",", $supports);



    for ($i = 1; $i <= 5; ++$i) {
        $pid = pcntl_fork();

        if (!$pid) {
            sleep(1);
            print "In child $i\n";
            exit;
        }
    }

  ?>

EDIT: I Tried running that same script on the server without forking and I got all the results right (after waiting a lot and getting my website stuck for a while..)

Upvotes: 0

Views: 107

Answers (0)

Related Questions