How to kill process started by user?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • opt_inf_env@yahoo.com

    #1

    How to kill process started by user?

    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?

  • Carl

    #2
    Re: How to kill process started by user?

    opt_inf_env@yah oo.com wrote:[color=blue]
    > 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?
    >[/color]

    What operating system is the server running?

    Carl.

    Comment

    • Colin McKinnon

      #3
      Re: How to kill process started by user?

      opt_inf_env@yah oo.com wrote:
      [color=blue]
      > 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?[/color]

      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.

      Comment

      Working...