How can I make Apache kill the CGI's that it has spawned, after the client (browser) has closed the connection?
I got a couple of CGI's that perform long-running operations and send output every 15 seconds. As soon as the browser closes the connection, the CGI (and its descendants) should be properly killed instead of lingering around my system and keeping valuable Apache slots occupied.
Preferably Apache should kill them. If not, I would like to know if there is way for the CGI to detect whether the connection with the browser has gone away.
Edit: apparently, the CGI's will have their STDOUT closed. Upon writing, they'll get a SIGPIPE signal and could act accordingly (usually they ignore this signal). In Perl, you could do:
print "fresh output\n" or die "apparently my audience has left the building";
So the question remains: could Apache detect the broken pipe and clean up its garbage?
Running on Debian w/ Apache 2.2.20, and normal suexec mechanism.
Thanks!
0 Answers