Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If a user hits stop in his browser, the Perl cgi is killed. I would like to know how this works and how to catch the termination in order to have time to clean up a few things. I have tried to catch all the signals I knew but it doesn't seem to work that way. Could sby give me some help on this ? Thanks.

Replies are listed 'Best First'.
Re: Apache Problem
by btrott (Parson) on Mar 03, 2000 at 23:21 UTC
    If you're running under mod_perl, take a look at this section of the mod_perl guide and the Apache::SIG module.
Re: Apache Problem
by Crulx (Monk) on Mar 04, 2000 at 06:08 UTC
    btrott's answer is correct. If you are not using mod_perl or Apache::SIG (i.e. you don't have any control over the webserver used) Then you have to catch SIGPIPE on stdout. Set up your program to do this and you should be ok. Basically, you just have to catch the signal on the perl side of things before the web server's handler does the work for you.
    ---
    Crulx
    crulx@iaxs.net