pcntl and libphp4.so , Does it work ?
Moderator: General Moderators
pcntl and libphp4.so , Does it work ?
Hello every body ,
I have compiled php with pcntl support. pcntl function works fine with the binary version of php. but when trying to work with it from under apache webserver. i got
Fatal error: Call to undefined function: pcntl_fork() in ....
i checked phpinfo it showed that php module was compiled with --enable-pcntl , but thats it no other module information. I am not sure if it should show other information or no !
Configure Command './configure' '--with-apxs=/opt/lams/servers/apache/bin/apxs' '--with-mysql=/opt/lams/servers/mysql/' '--with-gd' '--with-jpeg-dir=/usr' '--with-curl=/usr' '--with-zlib-dir=../zlib' '--enable-gd-native-ttf' '--with-config-file-path=/opt/lams/conf/php' '--with-xml' '--with-ttf' '--with-freetype-dir=../freetype-2.1.4' '--with-t1lib=../t1lib' '--with-png-dir=/usr/local' '--enable-pcntl'
I am runnign apache 1.3.29 with php 4.3.4 , on redhat ES 3
Thanks
Derek
I have compiled php with pcntl support. pcntl function works fine with the binary version of php. but when trying to work with it from under apache webserver. i got
Fatal error: Call to undefined function: pcntl_fork() in ....
i checked phpinfo it showed that php module was compiled with --enable-pcntl , but thats it no other module information. I am not sure if it should show other information or no !
Configure Command './configure' '--with-apxs=/opt/lams/servers/apache/bin/apxs' '--with-mysql=/opt/lams/servers/mysql/' '--with-gd' '--with-jpeg-dir=/usr' '--with-curl=/usr' '--with-zlib-dir=../zlib' '--enable-gd-native-ttf' '--with-config-file-path=/opt/lams/conf/php' '--with-xml' '--with-ttf' '--with-freetype-dir=../freetype-2.1.4' '--with-t1lib=../t1lib' '--with-png-dir=/usr/local' '--enable-pcntl'
I am runnign apache 1.3.29 with php 4.3.4 , on redhat ES 3
Thanks
Derek
i mean by binary version the command line php when i go :
php test-script.php
it works fine , and here is what i have inside the test script :
fromt he command line this test script will run fine, but if i try to do http://www.mydomain.com/test-script.php
i get call to undefiened function pcntl_fork !!!
can you please explain how to compile php as a cgi-module.
php test-script.php
it works fine , and here is what i have inside the test script :
Code: Select all
<?php class Process
{
function go()
{
$handle = fopen ("/root/test.txt","w+");
for ( $i=1; $i<1000000; $i++ ) {
fwrite($handle,"WRITTING MANY LINES TO FILE\n");
}
fclose($handle);
}
}
$pid = pcntl_fork();
if ( !$pid)
$pid = pcntl_fork();
if ($pid) {echo "location: http://www.google.com"; exit();}
else {
$process = new Process();
$process->go();
die();
}
pcntl_waitpid($pid, &$status, 0);
?>i get call to undefiened function pcntl_fork !!!
can you please explain how to compile php as a cgi-module.
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
It explains it in the php installation readme. You can compile it as an apache module or as a cgi module, and I think pcntl needs to be as an cgi module.
http://www.php.net/manual/en/install.commandline.php
Also, in the ./configure, might want to enable sockets and sigchild too.
http://www.php.net/manual/en/install.commandline.php
Also, in the ./configure, might want to enable sockets and sigchild too.
It means you can't use pcntl_* functions if php is compiled as apache module.PHP manual wrote: LXXXIV. Process Control Functions
Introduction
Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination. Process Control should not be enabled within a webserver environment and unexpected results may happen if any Process Control functions are used within a webserver environment.
- Pyrite
- Forum Regular
- Posts: 769
- Joined: Tue Sep 23, 2003 11:07 pm
- Location: The Republic of Texas
- Contact:
Nope. Not according to php's manual anyways.
I know there are some 3rd party php builds for Windows that have this enabled. But that probably won't help you, since pcntl is really a Unix thing. And you could probably also call the script in question with the CLi php with a system() or exec() function to get the output, but that probably won't help you much either
I know there are some 3rd party php builds for Windows that have this enabled. But that probably won't help you, since pcntl is really a Unix thing. And you could probably also call the script in question with the CLi php with a system() or exec() function to get the output, but that probably won't help you much either
Actually , i was thinking of doing this,
i will post back in this forum if this worked for me.
its a performance tradeoff, the script i am writting redirects user after sending some may be 15 MySQL update/insert/ read queries to the dataabase . i am trying to get the redirection done , without user waiting for the logging process to be finished. the script i posted above is the TEST situation. if system call will be less time to execute than to wait for logging to fiinish , i will do it.
Thanks to every body who tried to help here, if you guys have any ideas on a simpler way to do that , i will be glade to hear it
i will post back in this forum if this worked for me.
its a performance tradeoff, the script i am writting redirects user after sending some may be 15 MySQL update/insert/ read queries to the dataabase . i am trying to get the redirection done , without user waiting for the logging process to be finished. the script i posted above is the TEST situation. if system call will be less time to execute than to wait for logging to fiinish , i will do it.
Thanks to every body who tried to help here, if you guys have any ideas on a simpler way to do that , i will be glade to hear it