Fatal error: Call to undefined function pcntl_fork()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Fatal error: Call to undefined function pcntl_fork()

Post by jaoudestudios »

I am trying to take advantage of forking in php, a kind of multi-threading.

However, I keep getting an error.....Fatal error: Call to undefined function pcntl_fork(). Yet I have re-compiled the latest version of php 5.2.9 with --enable-pcntl.

Any ideas what else I am missing?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Fatal error: Call to undefined function pcntl_fork()

Post by Weirdan »

Are you running your script from command-line?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Fatal error: Call to undefined function pcntl_fork()

Post by jaoudestudios »

Fixed it! Yes that was my problem. Thanks away.

How come it only runs from the command line?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Fatal error: Call to undefined function pcntl_fork()

Post by Weirdan »

jaoudestudios wrote:How come it only runs from the command line?
Straight from the docs:
Pcntl docs wrote:Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.
Post Reply