我有一个Perl CGI应用程序,有时会超时,导致它被Apache杀死,并将504 Gateway Time-out错误发送到浏览器。我正在尝试使用NYTProf对此应用程序进行配置文件,但是我无法读取配置文件数据:

 $ 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)

我正在使用sigexit=1 NYTProf选项。这是重现问题的最小CGI脚本:
#!/usr/bin/perl -d:NYTProf

sleep 1 while 1;

最佳答案

设置sigexit=1告诉NYTProf捕获以下信号:

INT HUP PIPE BUS SEGV

但是,当您的CGI脚本超时时,Apache将发送SIGTERM。您需要捕获SIGTERM:
sigexit=term

要捕获除默认信号之外的SIGTERM,请使用:
sigexit=int,hup,pipe,bus,segv,term

09-25 20:27