Jump to content

how can I kill a running child process when client closes connection


mickyt

Recommended Posts

Hi,

I'm relatively new to PHP (also new here), but have already tried varies places for help. This is my problem:

running PHP5 under Apache 2.2 (prefork) as module, I call a Python script that does a sometimes lengthy MySQL query, using parameters supplied by the browser client. When the query takes too long, the user may want to press the STOP button and issue a different query. But the previous child process will run to completion in any case, wasting server resources at the very least. In the current setting there seems to be no way to forward the user action to kill the child process. The system() call is blocking, and the only chance to see the closed connection in the PHP script is after it has returned.

Is there a work-around? I'm advised not to use the pcntl_fork() etc. in embedded PHP. Are there other possibilities?

Please don't say I should have done everything directly in PHP, without a system() call. I'm much better in Python, that's the reason why, and also I think the call to execute_query (or whatever it is called) directly from within PHP will block as well.

 

Any suggestions, best proven real-life solutions, are welcome. I thought this must be an everyday problem, or?

 

Thanks for your help

Michael

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.