in reply to cleanup a cancelled CGI script

IIRC, the script doesn't actually die when the user hits STOP on their Web browser; I'm not aware of any mechanism to inform the script of this. Instead, when the script tries to send data back to the user, it sees that the socket has been closed, and receives a SIGPIPE. I believe that installing a signal handler for this signal will allow you to detect when this has happened:
$SIG{PIPE} = sub { die "Connection closed while processing!\n" }

Replies are listed 'Best First'.
Re^2: cleanup a cancelled CGI script
by diotalevi (Canon) on Jun 08, 2004 at 19:10 UTC

    If you take the following approach in addition, you've got a nice way to handle those issues and others as well.

    eval { do_stuff( ... ); 1; } or cleanup( ... )