"Shawn O. Pearce" [off-list ref] writes:
If stdout has already been closed by the CGI and die() gets called,
the CGI will fail to write the "Status: 500 Internal Server Error" to
the pipe, which results in die() being called again (via safe_write).
This goes on in an infinite loop until the stack overflows and the
process is killed by SIGSEGV.
Before looking at the code I first thought "wouldn't we have the same
problem in die(), and shouldn't we have "dying" flag there?" but I was
stupid as usual ;-)
The patch looks sane. Thanks.