Jump to content

krups

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

krups's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. How can we call a function from within a C++ library in PHP. Can we link to a C++ library by using dl()?
  2. I am trying to load an external module (C++ library- libTest.so) by using dl(). We are using PHP 4.3.9 and it has been built using CGI. phpTest.php file has the following line: dl('libTest.so'); We get the following error: Warning: dl(): Invalid library (maybe not a PHP library) 'libTest.so' Is it that we cannot load C++ modules in PHP?
  3. I am trying to load an external module in PHP by using dl(). We are using PHP 4.3.9 and it has been built using CGI. phpTest.php file has the following line: dl('libTest.so'); We get the following error: Warning: dl(): Invalid library (maybe not a PHP library) 'libTest.so'
  4. Hi, We are using apache server on linux with PHP 5. Could you please give me an example of steps so as to be able to build an extension and call a function from within third-party's C++ library. like: libFoo.so Thanks, Krupa
  5. I have a C application foo.c which generates libFoo.so. foo.c #include <stdio.h> int FooBar(int value) { printf("Hello, World.\n"); return 1; } I want to load this libFoo.so into index.php file and call FooBar(); from libFoo.so. dl(libFoo.so); FooBar(); This does not work in PHP. What is the correct way to implement this functionality? -------------------------------------------------------------------------------------------- I tried to create an extension "myfile" (using ./ext_skel) which has FooBar() function defined. But I am not able to call FooBar() function defined in foo.c. Through PHP_FUNCTION(FooBar) (defined in ext/myfile.c), I want to call FooBar() implemented in foo.c. Kindly help how should this be implemented. Thanks, Krups
  6. Thanks a lot for your reply. The PHP GUI cannot directly talk to the test application. We have another executable (Console- executes MML commands) this Console application can talk to the test application. So in the PHP GUI what we do is pass a command to the console application. This command brings up the application, excutes the command and after executing the command the console application exits and is closed down. PHP successfully brings up the console application, executes the command and then also the console application is closed. PHP does not hang here but there is a defunct process left of the console application. We need to run this console application. PHP GUI is like a web interface to the console application. Both the test application and console application are written in C++. If we manually bring up test application (as root) and also console application (as root) and execute the same commands that we would through PHP GUI then there is no defunct process left. Everytime we click the PHP GUI it calls the console application as mentioned above. Only problem is we do not want to see a whole list of defunct processes after each click on the GUI. What would be the best way to avoid the defunct process.  After we added --enable-sigchild' to configure command in PHP we do not get defunct process after every time we click the PHP GUI. But we still get defunct process a lot of times.... what's different is that the defunct process might also eventually go away if the parent process id is still there.... I mean a lot of child process id's are present for the same parent process id. Then if we click on the GUI then the defunct processes are gone. But if we do not click the GUI for a while and there is now a new parent process id then old defunct processes stay. PHP does not hang when we call the console application. I was trying to write code to kill all existing defunct processes using "kill -9 ppid" this time PHP hangs.... But if we can avoid getting defunct processes then we do not need to kill any process. The configure option is as mentioned below. './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-mm=/usr/local' '--enable-sigchild' '--enable-force-cgi-redirect' '--enable-discard-path' '--enable-fastcgi' '--enable-pcntl' '--enable-posix' Code after which php will leave a defunct process. Note PHP does not hang here it executes successfully but leaves a defunct process. $command="dbc/Console -socket spc_disp_config 1"; exec($command,$status,$dresult); Thanks, Krups
  7. Sorry my mistake this application if we bring it up manually it runs as root and does not leave any defunct process behind. But when we run it through PHP GUI it runs as user nobody.  Actually we have 2 applications running one (C++) Test application which we start manually as user "root" on command line then through the PHP GUI we call another application(one which is leaving a defunct process), this application talks to our test application, sends message to the test application and changes certain configuration parameters of the test application while the test application is running. The PHP gui is nothing but a web interface of the application which talks to the test application. Can I run the application as user root through php by using 'sudo' instead of user nobody? I have not used sudo before.... Thanks, Krups
  8. Thanks for your response. apache is running as user "nobody" and the application called inside exec(), which leaves a defunct process is another user "root". I cannot run apache as root. So what is the best thing to do?
  9. exec(), system(), passthru(), shell_exec(). These commands when executed always left a  defunct process.  Then when I reconfigured php with --enable-sigchild option it was better as now it does not leave a defunct process always..... but mosttimes we still get defunct process. I wrote code to kill defunct process. The code executes correctly. The defunct process also gets killed but later the page is not displayed.  Looks like php hangs. exec("/bin/kill -9 $ppid"; system("/bin/kill -9 $ppid /dev/null/ 2>&1 &"); passthru(kill -9 $ppid &); shell_exec(bin/kill -9 $ppid &); Also tried posix_kill($ppid, 1); where $ppid is parent process id. Is there any conifuration options that I should use or any php.ini parameters that I should change. Please help me with this query. We are using PHP with apache. The configure option is as mentioned below. './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-mm=/usr/local' '--enable-sigchild' '--enable-force-cgi-redirect' '--enable-discard-path' '--enable-fastcgi' '--enable-pcntl' '--enable-posix'
  10. Got no replies for my query. Please can someone suggest if I am missing any configuration parameters or any php.ini parameters to solve this problem.
  11. I am new to php and have a problem with the following php commads. exec(), system(), passthru(), shell_exec(). These commands when executed always left a  defunct process.  Then when I reconfigured php with --enable-sigchild option it was better as now it does not leave a defunct process always..... but mosttimes we still get defunct process. I wrote code to kill defunct process. The code executes correctly. The defunct process also gets killed but later the page is not displayed.  Looks like php hangs. exec("/bin/kill -9 $ppid";); system("/bin/kill -9 $ppid /dev/null/ 2>&1 &"); passthru(kill -9 $ppid &); shell_exec(bin/kill -9 $ppid &); Also tried posix_kill($ppid, 1); where $ppid is parent process id. Is there any conifuration options that I should use or any php.ini parameters that I should change. Please help me with this query. We are using PHP with apache. The configure option is as mentioned below. './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-mm=/usr/local' '--enable-sigchild' '--enable-force-cgi-redirect' '--enable-discard-path' '--enable-fastcgi' '--enable-pcntl' '--enable-posix'
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.