Page 1 of 1

Hang on browser stop button in middle of system() call

Posted: Fri Oct 01, 2010 9:29 am
by pgalpern
I am using PHP system() calls to run third party software. This software dumps output which is then forwarded to the browser synchronously. If the user hits the browser STOP button at the wrong time everything hangs, and all subsequent requests from that name-based virtual server (Apache) do not respond until the web server is restarted. Other virtual servers continue to work normally. Although a mySQL connection is involved, I do not think this is the problem as I can force closure of any open threads and the problem is not solved. I cannot, however, force closure of the process spawned by the system() call with Admin privs (on Windows 2003).

Can anyone:
(a) Tell me what they think is happening here; or
(b) Suggest a quick fix way to fix this without requiring restart

Thanks for you help.

Re: Hang on browser stop button in middle of system() call

Posted: Fri Oct 01, 2010 9:45 am
by pickle
My immediate guess would be the culprit is the 3rd party software, or maybe IIS.

Re: Hang on browser stop button in middle of system() call

Posted: Fri Oct 01, 2010 9:47 am
by VladSun
A quick fix:

Code: Select all

ignore_user_abort();
set_time_limit(0);
at the top of the page.

A real fix might be a Linux server :P

Re: Hang on browser stop button in middle of system() call

Posted: Fri Oct 01, 2010 10:39 am
by pgalpern
Yes--linux would be nice, however box needs to run Windows 2003. Apache/PHP instead of IIS are consolation prizes.

I tried ignore_user_abort() and set_time_limit(). Thank you for these suggestions. However this does not solve the problem. I also tried setting max_execution_time in configuration to 10 seconds, and it still does not recover after 10 seconds. Full Apache shutdown still required.

If it is the third-party software (happens to be R - statistical software interpreter) that is hanging, then how can I uncouple PHP (or is it Apache?) from hanging with it.

I am using system() calls rather than passthru() because I need R to send stuff to the browser synchronously. It is running long analyses, and it reports on its progress as it goes. passthru() only reports upon completion of the spawned process, it seems.

Thanks

Re: Hang on browser stop button in middle of system() call

Posted: Fri Oct 01, 2010 10:49 am
by pgalpern
Another possibility--could it be related to the fact that output buffering is _not_ being used in order that output from the third-party software is sent in real-time.