Profiling a Perl CGI script that times-out

cgi, devel-nytprof, http-status-code-504, perl

Solution

Setting `sigexit=1` tells NYTProf to catch the following signals:

INT HUP PIPE BUS SEGV

However, when your CGI script times out, Apache sends `SIGTERM`. You need to catch `SIGTERM`:

sigexit=term

To catch `SIGTERM` in addition to the default signals, use:

sigexit=int,hup,pipe,bus,segv,term

Problem

I have a Perl CGI application that sometimes times out, causing it to be killed by Apache and `504 Gateway Time-out` error to be sent to browser. I am trying to profile this application using NYTProf, however I cannot read profile data: ``` $ nytprofhtml -f www/cgi-local/nytprof.out Reading www/cgi-local/nytprof.out Profile data incomplete, inflate error -5 ((null)) at end of input file, perhaps the process didn't exit cleanly or the file has been truncated (refer to TROUBLESHOOTING in the documentation) ``` I am using `sigexit=1` NYTProf option. Here's minimal CGI script that reproduces problem: ``` #!/usr/bin/perl -d:NYTProf sleep 1 while 1; ```

Original source