http://qs321.pair.com?node_id=362515


in reply to cleanup a cancelled CGI script

I tried the solution of using SIGPIPE posted by others above on Windows XP just to try it. Of course, there is no SIGPIPE sent to the script when running under Win32 (well, WinXP anyhow). What happened in my test is that the script doesn't even realize that the client has disconnected. The script finishes running normally, with no change in execution (in a simple test anyhow). Even adding a or die("print failed: $!"); to a print statement that should fail doesn't change anything. My test script below:

#!perl -w $| = 1; BEGIN { $SIG{PIPE} = sub { die "Pipe error: @_\n" }; } use strict; use CGI; my $q = CGI->new(); print $q->header(); print "output #1\n"; sleep 15; # we stop the browser load during the 15 sec. sleep print "output #2\n" or die("print failed: $!"); END { open my $fh, '>>', 'debug.txt'; print $fh "We made it to the END block.\n"; close $fh; }