RE: CGI-database interaction

Dan Howard (howard.dan@baznet.ic.gc.ca)
Wed, 29 Jan 1997 00:02:25 GMT


(A copy of this response posted to comp.infosystems.www.authoring.cgi
as "Handling early termination of CGIs")

On January 28, 1997, xec@morgan.com wrote:

>Does any one know how perl5 handles when client
>click on "STOP" or "BACK" button in the browser?
>What kind of signal does it get and is it sure
>that it proceeds to the END?

I'm not sure if I understand your question correctly, and I'm not sure
that it is an LWP-specific or even a perl-specific question.  If what
you mean is "What happens to a CGI program running on my server if the
user clicks Stop or Back before they're done seeing its output?", then
here's the answer:

I assume that your web-server wouldn't start your CGI program in the
first place if the user clicked stop before the browser was done
sending any POST or GET info (I haven't tested this part).

However, once the CGI is started it continues running and sending its
output to the browser, even if the browser is no longer "listening".
I wrote a simple program called "forever.cgi".  When you call it with
Netscape, it just starts printing numbers on your screen, one every
second:  "1...2...3..." etc.  If you click Stop, then the famous
"Transfer interupted!" appears on the screen.  But if you do a "ps -ef
| grep forever" from the unix prompt on the server, you'll see the
program is still there, chugging happily away all by itself.  You have
to terminate it manually.

I hope this answers your question.

Dan Howard