Re: How to kill process started by user?



opt_inf_env@xxxxxxxxx wrote:

> Hello,
> Let us suppose that PHP file contains cycle which will never stop. For
> example:
> while ( 2==2 )
> {
> some usage of database;
> }
> User which opens this PHP page runs time consuming execution of the
> cycle. My question is whether this execution will be automatically
> stopped after user closes the PHP file (or closes his browser). I
> suppose that answer is "No", since PHP is server-side application.
> How than I can find such processes and kill them by hands?

Every so often PHP will check to see how long it has been executing and
whether the user has disconnected. You can explicitly control the behaviour
of PHP in this regard. However as you allude to, if PHP is waiting for
information (e.g. from a database query) these checks are not carried out.
IME memory usage behaves similarly, at least with the mysql extension.

So really this leaves two problems:

1) identifying when it happens
2) killing the process when it does

But these are very much dependent on the operating system, the webserverand
the level of access you have. On my machines (Linux) I have root access and
a cron job which runs every 5 minutes to check for apache processes
(mixture of 1.3 and 2.0 with seperate processes) using lots of memory by
parsing the output of the ps command. When it finds one it sends a HUP. If
you're using IIS or don't have root access, life is likely to be a lot more
tricky.

HTH

C.
.



Relevant Pages

  • Re: PHP Performance and System Load
    ... Most of for examples of php look like this ... In every cycle you call sizeof ... $intSize = sizeof; ...
    (php.general)
  • Re: Text file splitter, date/time field
    ... large text file into which I have copied PHP file after PHP file, ... You appear to want to write code in a language that you do not know. ... Perl's regular expression in the documentation that came with perl. ...
    (comp.lang.perl.misc)
  • [UNIX] YaPiG add_comment.php PHP Code Injection
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... YaPiG is "a simple but powerful web album ... * YaPiG version 0.92b (Latest downloaded files appear to be immune to PHP ... This Proof of Concept creates a php file that echoes a notice. ...
    (Securiteam)
  • php code compiles, produces good html output, but crashes when put through browser
    ... This is a postgresql/PHP running with PHP 5. ... The postgres part works fine, and the html that is generated is OK, but the .php file hangs when I run it through the browser. ... I need some basic debugging tools that I don't have to figure out what is going on. ...
    (php.general)
  • Re: How to call different methods in one PHP file?
    ... > I'm a PHP newbie coming from experience with ASP.NET. ... It isn't good programming style to use one PHP file per HTML page. ... should be based on functionality, ... You should group functions/methods by functionality rather than ...
    (comp.lang.php)