Project

General

Profile

[Solved] mod_cgi, lighty not killing CGI if connection in the other end is closed

Added by UAbounfire64 over 5 years ago

I have a CGI called upon a browser request, the CGI starts up waits for some information with a select call.
The browser may not wait that long and disconnect (client side xhr.abort() call)
Lighty does not kill the CGI process as I expected even though the connection is closed.
A rough look through mod_cgi.c indeed shows that a kill(pid, SIGTERM) should have been sent to the CGI child process if the browser goes away.

Easy to reproduce, installed lighty from sources (latest version) on Ubuntu 13.04, written a mini CGI in python that basically just sleeps and waits to be killed once the browser disconnects or closed, which of course never happens.

Any reason why ?

Regards,

The conf is minimal (copied and pasted from examples):
server.document-root = "/home/user/www/"

server.port = 80

server.username = "user"
server.groupname = "user"

mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)

static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", "~", ".inc" )
index-file.names = ( "index.html" )

server.modules += ( "mod_cgi" )

cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python" )


Replies (2)

RE: [Solved] mod_cgi, lighty not killing CGI if connection in the other end is closed - Added by gstrauss almost 2 years ago

Fixed since lighttpd 1.4.40, released July 2016. Latest release of lighttpd is currently lighttpd 1.4.48.

RE: [Solved] mod_cgi, lighty not killing CGI if connection in the other end is closed - Added by gstrauss almost 2 years ago

Actually, this requires explicit use of POLLRDHUP on Linux, so I'll look into adding something for lighttpd 1.4.49. In the meantime, server.max-read-idle and server.max-write-idle and server.max-keep-alive-idle can be used to configure idle timeouts.

    (1-2/2)