You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Justin Erenkrantz <ju...@erenkrantz.com> on 2004/12/19 08:40:03 UTC
Behavior of long-running CGI scripts?
What is *supposed* to be the behavior of long-running CGI scripts that have
their connections closed on them before they complete? Are they supposed to
finish, or abort prematurely? Do they receive some signal when the parent
closes its handle?
With httpd-2.1, if I add the following to the end of the test-cgi script:
---
echo "--`date`--" >> /tmp/this-is-a-test
sleep 300
echo "Hello World"
echo "Hello" >> /tmp/this-is-a-test
echo "--`date`--" >> /tmp/this-is-a-test
---
Then, I issue a HTTP request for /cgi-bin/test-cgi and then close the
connection before the sleep expires. I will *not* see the Hello or final date
in my log, but I do see the first date. If I lower the value to be less than
300 seconds (300 is the default server Timeout), it's okay and I see the
'right' output.
The reason I'm asking this is that if this analysis is correct, then I think
we're seeing some brokenness on svn.apache.org due to this behavior. -- justin
Re: Behavior of long-running CGI scripts?
Posted by Joe Orton <jo...@redhat.com>.
OK, a month late, but...
On Sat, Dec 18, 2004 at 11:40:03PM -0800, Justin Erenkrantz wrote:
> What is *supposed* to be the behavior of long-running CGI scripts that have
> their connections closed on them before they complete? Are they supposed
> to finish, or abort prematurely? Do they receive some signal when the
> parent closes its handle?
You're seeing expected behaviour, I think.
httpd only finds out that the TCP connection was closed as and when it
tries to write to it. So if the CGI script doesn't write anything for >
Timeout seconds, the server never finds out that the connection was
aborted, and the normal timeout handling applies. i.e. the script is
ignored until r->pool is destroyed, when the pipes are closed then the
script is SIGTERMed (or SIGKILLed if it hangs around ignoring SIGTERM)
is that any use?
joe