PHP Warning: exec() unable to fork

Solution 1:

Process limit

"Is there a process limit I should look into"

It's suspected somebody (system admin?) set limitation of max user process. Could you try this?

$ ulimit -a
....
....
max user processes              (-u) 16384
....

Run preceding command in PHP. Something like :

echo system("ulimit -a");

I searched whether php.ini or httpd.conf has this limit, but I couldn't find it.

Error Handling

"even a better way to handle these processes as to get around the error all together?"

The third parameter of exec() returns exit code of $cmd. 0 for success, non zero for error code. Refer to http://php.net/function.exec .

exec($cmd, &$output, &$ret_val);

if ($ret_val != 0)
{
    // do stuff here
}
else
{
    echo "success\n";
}

Solution 2:

In my case (large PHPUnit test suite) it would say unable to fork once the process hit 57% memory usage. So, one more thing to watch for, it may not be a process limit but rather memory.