Re: note 24573 added to function.pcntl-fork
| From: | Jesus M. Castagnetto | Date: | Wed, 21 Aug 2002 21:54:28 +0000 |
| Subject: | Re: note 24573 added to function.pcntl-fork | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35334@lists.php.net to get a copy of this message | ||
This type of questions should go to one of the mailing
lists not the notes.
Your note will be removed
--- kingmundi@hotmail.com wrote:
> Regarding the
> 'Call to undefined function: pcntl_fork() in...'
>
> You have to configure pcntl before building php.
> It apparently only works when you make the
> standalone php binary. I have built such a
> standalone binary and gotten the daemon
> process to work. Example...
>
> #!/usr/local/bin/php -q
> <?
> function daemonize()
> {
> $pid = pcntl_fork();
> if ($pid == -1)
> die("could not fork");
> else if ($pid)
> exit(); //we are the parent
>
> return $pid;
> }
>
> if(daemonize() == 0)
> {
> if(daemonize() == 0)
> {
> //do daemon work here
> //just a dummy loop to keep it running
> while(1)
> $x++;
> }
> }
> ?>
>
> now from a command line you can run it
> (if you have the file saved as daemon.php)
> ./daemon.php
>
> and it will spawn off a new process.
>
> However, I can not figure out why if you call
> the script from a webpage script using the
> system() or exec() functions like so
>
> <?
> system("/var/somewhere/daemon.php");
> ?>
>
> The page sits and sits and waits for the
> function to finish before it is done loading the
> page. Very different behaviour from running
> it from the command line.
>
> You can of course manually stop loading the
> page (and the daemon.php program is still
> running as a process on the server). It is as
> though the parent process is the apache mod
> php and it is waiting on its child (the
> daemon.php) except I thought doing a double
> fork would prevent this.
> --
> http://www.php.net/manual/en/function.pcntl-fork.php
>
http://master.php.net/manage/user-notes.php?action=edit+24573
>
http://master.php.net/manage/user-notes.php?action=delete+24573
>
http://master.php.net/manage/user-notes.php?action=reject+24573
>
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
--- Jesus M. Castagnetto <jmcastagnetto@php.net>
__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com