Aarg!
I don't think there's a good solution to this so I'm going
to vent a bit (I'm a mild mannered venter), but if you see something I'm missing, please let me know.
The basics: I'm running Win98, Apache, PHP 4.05, Curl.
So unfortunately, passthru, exec, and backticks are pretty well broken in PHP and scheduled to fixed in PHP 4.06 (hurrah!).
I have a server page, call it Server.php and a straightforward dosbox php program, call it Munger.php
When Munger.php is called (via php -q Munger.php arguments...) it uses Curl (a most excellent program) to grab some pages (real time) and extract some info from them, then take action. Works great. Server.php pops up a web page for the client, gets some information via a form, and then wants to return a status page to the client. This page is happy, too, except for one thing.
In one case, as the very last measure before tidying up, Server.php must call out to Munger.php and it must do it right away. No dilly dallying, since munger.php must get to work right away. However, munger.php might be at its task for quite a while (several minutes, even though it must start quickly), and Server.php is not inlined to wait, nor does it need any feedback from Munger.php
Ideas. 1) Rewrite Munger.php to not exit by using die. But even if I do this, I tie Server.php to Munger.php and must wait for the output.
2) Invoke passthru, backticks, or exec. Even if they weren't broken (and yes I am using complete paths), passthru and backticks are out (as I understand) since they create a separate shell which Server.php would definitely wait for. But this still didn't work, even for a nice little .exe test file.
3) This may be useful to some since it at least allows running a standard .exe file: I open an Excel COM object, create a VB function within a workbook whose only function is to Exec the string that I pass it (via $Excel->Run (MyVBExecFunction, StrToExec)). It might be wedged but it works.
Unfortunatley, all bets seem to be off on reinvoking php while Server.php is still processing (I.e. with php -q Munger.php arguments ...). It doesn't give me an error (but maybe that is because Excel is the one doing the Exec-ing), but I don't get any output either.
4) My other idea on this was to use 3) to invoke the
windows scheduler to run Munger.php at the next available point in time, but it only seems to do the scheduling on the minute, and Munger.php does not have that kind of time to burn.
So, being out of clever tricks, my issue is with PHP not being reentrant. Maybe someone will tell me that I'm wrong.
Csaba Gabor