For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2004 > Killing a Process









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Killing a Process
Kevin Bass

2004-11-21, 3:55 pm

I have a slight problem that I am attemping to solve. I am using CGI/Perl
(DBD Oracle) on Linux AS 2.1 to access to the database. When users encounter
problems on the web, they cancel (or press stop) in their browsers. This
will stop there browser interaction and also cause the database connection
to not disconnect which causes a runaway process. Is there an article that I
can read or a procedure/module or process that someone has written within
CGI or DBI (or sometimes else) that will allow me to kill my database
connection when a users stops an execute within his/her browser? Thanks!

Kevin

Bob Showalter

2004-11-22, 3:55 pm

Kevin Bass wrote:
> I have a slight problem that I am attemping to solve. I am using
> CGI/Perl (DBD Oracle) on Linux AS 2.1 to access to the database. When
> users encounter problems on the web, they cancel (or press stop) in
> their browsers. This will stop there browser interaction and also
> cause the database connection to not disconnect which causes a
> runaway process. Is there an article that I can read or a
> procedure/module or process that someone has written within CGI or
> DBI (or sometimes else) that will allow me to kill my database
> connection when a users stops an execute within his/her browser?
> Thanks!


When the user presses the "Stop" button on their browser, the only thing
that happens is the connection back to the server is closed. The only way
for your script to detect this is to try to send data back to the client. If
the connection is closed, you'll receive SIGPIPE (which by default will
terminate your process).

You can catch the SIGPIPE and do a graceful shutdown on the db connection.

If you're in the middle of a query, you won't be able to detect the
connection being closed until the DBI call returns.
Henri Asseily

2004-11-22, 8:55 pm


On Nov 22, 2004, at 5:30 AM, Bob Showalter wrote:

> Kevin Bass wrote:
>
> When the user presses the "Stop" button on their browser, the only
> thing
> that happens is the connection back to the server is closed. The only
> way
> for your script to detect this is to try to send data back to the
> client. If
> the connection is closed, you'll receive SIGPIPE (which by default will
> terminate your process).
>
> You can catch the SIGPIPE and do a graceful shutdown on the db
> connection.
>
> If you're in the middle of a query, you won't be able to detect the
> connection being closed until the DBI call returns.
>


Note that while a plain CGI script might get a SIGPIPE, it won't be the
case under mod_perl. There are no pipes under mod_perl and I have no
idea how one would go about knowing if the user severed the connection.

Henri Asseily

2004-11-22, 8:55 pm

On Nov 22, 2004, at 5:30 AM, Bob Showalter wrote:

> Kevin Bass wrote:
>
> When the user presses the "Stop" button on their browser, the only
> thing
> that happens is the connection back to the server is closed. The only
> way
> for your script to detect this is to try to send data back to the
> client. If
> the connection is closed, you'll receive SIGPIPE (which by default will
> terminate your process).
>
> You can catch the SIGPIPE and do a graceful shutdown on the db
> connection.
>
> If you're in the middle of a query, you won't be able to detect the
> connection being closed until the DBI call returns.
>


I take back my previous email. For mod_perl please check the docs:

http://perl.apache.org/docs/1.0/guide/
debug. html#Handling_the__User_pressed_Stop_but
ton__case

H

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com