PHP Fatal error:call to undefined function pcntl_fork ()

Source: Internet
Author: User
Problem Descriptio n:





[Root@localhost www]#/usr/local/php/bin/php index.php



PHP Fatal error:call to undefined function pcntl_fork () in/home/www/theard/threadprocessmanager.php on line 69



Workaround:









1. New PHP Compilation



./configure--enable-pcntl "" "



2, do not reinstall can also, directly into your installation of PHP source directory ext/pcntl directory.






Run



Phpize

[Root@localhost pcntl]#./configure--with-php-config=/usr/local/php/bin/php-config && make && make Install



Put the generated files in the default directory:



[Root@localhost pcntl]# cp/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/pcntl.so/usr/lib/php/ modules/



and add this extension to the php.ini.
Extension=pcntl.so
If you do not add it directly in your program (with the DL () function, the function will be canceled) can also, especially for PHP in addition to CmdLine and Apache do web work, because the Web service load PNCTL module love problems.






Test method




test_fork.php:

echo "This was an echo before I called the fork command\n";

$pid = Pcntl_fork ();
if ($pid = =-1) {
Die ("Could not fork");
} else if ($pid) {
echo "I am the parent, PID =". $pid. " \ n ";
} else {
echo "I am the child, PID =". $pid. " \ n ";
}
echo "This is a echo after I called the fork command\n";
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.