[PHP] pcntl_fork doesn't work

2005-01-26 Thread John Davin
I'm trying to use pcntl_fork on php 4.3.10, but it says " Call to 
undefined function:  pcntl_fork() in test.php on line 3"".

The manual says pcntl is present in php >= 4.1.0.  I have 4.3.10, just the 
standard installation included on fedora core 3.

I've done all the standard stuff - google'd, searched mailing list 
archive, looked through phpinfo() (didn't find anything relevant).

Why wouldn't pcntl be working?  Is there any other way for me to fork a 
process or thread?

-John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: pcntl_fork doesn't work

2005-01-26 Thread John Davin
That's what I was afraid of.
My web host (totalchoicehosting) doesn't have pcntl compiled in either, 
so I'm sort of stuck.

Isn't there any other way to fork a process? PHP 
doesn't have thread support?  Why isn't pcntl enabled by default?
Surely the Windows compatibility isn't an issue, because pcntl could 
default to enabled in linux but disabled in windows.

I'll tell you what I'm trying to do, in case there's another way to do it: 
I have a logging script which does a gethostbyaddr to obtain the hostname 
of the visitor to my site. But gethostbyaddr can take long or time out on 
some IP's, so I want to fork it so that the original script can terminate 
and not prevent the webpage from loading.
I could run a background job which periodically does the gethostbyaddr on 
the IP's stored on disk, but that's sort of a hack, and is more 
complicated than if I could fork.

-John
On Wed, 26 Jan 2005, Ben Ramsey wrote:
John Davin wrote:
The manual says pcntl is present in php >= 4.1.0.  I have 4.3.10, just the 
standard installation included on fedora core 3.

Why wouldn't pcntl be working?  Is there any other way for me to fork a 
process or thread?
Take a look at http://www.php.net/pcntl.
If you're using the standard installation of PHP on FC3, then it won't have 
pcntl enabled with --enable-pcntl because it's not enabled by default. You 
will have to recompiled PHP with this feature.

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: pcntl_fork doesn't work [RESOLVED]

2005-01-26 Thread John Davin
Thanks. I had read about passthru before but missed the note about running 
a program in the background.
I ended up working out a solution using exec:
exec( "/usr/bin/php my_other_php_script.php arg1 arg2 arg3 &").
(passed some data to the other script on the commandline).

thanks,
-John
On Wed, 26 Jan 2005, Ben Ramsey wrote:
John Davin wrote:
Isn't there any other way to fork a process? PHP doesn't have thread 
support?  Why isn't pcntl enabled by default?
Surely the Windows compatibility isn't an issue, because pcntl could 
default to enabled in linux but disabled in windows.

I'll tell you what I'm trying to do, in case there's another way to do it: 
I have a logging script which does a gethostbyaddr to obtain the hostname 
of the visitor to my site. But gethostbyaddr can take long or time out on 
some IP's, so I want to fork it so that the original script can terminate 
and not prevent the webpage from loading.
I could run a background job which periodically does the gethostbyaddr on 
the IP's stored on disk, but that's sort of a hack, and is more 
complicated than if I could fork.
Sounds like passthru() might do what you want <http://us3.php.net/passthru>. 
Take a look at that manual page and read the first note about leaving the 
program running in the background.

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php