added a signal handler for FPE

This commit is contained in:
roberto@precise64
2012-02-22 12:00:32 +01:00
parent 87860da238
commit d3102df2bf
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -117,7 +117,7 @@ void carbon_master_cycle() {
if (rlen < 1) goto clear;
if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;}
rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.avg_rt %llu %llu\n", uwsgi.hostname, u_carbon.id, (unsigned long long ) total_avg_rt / avg_rt_workers, (unsigned long long ) uwsgi.current_time);
rlen = snprintf(ptr, 4096, "uwsgi.%s.%s.avg_rt %llu %llu\n", uwsgi.hostname, u_carbon.id, (unsigned long long ) avg_rt_workers ? total_avg_rt / avg_rt_workers : 0, (unsigned long long ) uwsgi.current_time);
if (rlen < 1) goto clear;
if (write(fd, ptr, rlen) <= 0) { uwsgi_error("write()"); goto clear;}
+14
View File
@@ -1105,6 +1105,19 @@ void uwsgi_segfault(int signum) {
exit(1);
}
void uwsgi_fpe(int signum) {
uwsgi_log("!!! uWSGI process %d got Floating Point Exception !!!\n", (int) getpid());
uwsgi_backtrace(uwsgi.backtrace_depth);
// restore default handler to generate core
signal(signum, SIG_DFL);
kill(getpid(), signum);
// never here...
exit(1);
}
#ifdef UWSGI_AS_SHARED_LIBRARY
int uwsgi_init(int argc, char *argv[], char *envp[]) {
@@ -1142,6 +1155,7 @@ int main(int argc, char *argv[], char *envp[]) {
//char *optname;
signal(SIGSEGV, uwsgi_segfault);
signal(SIGFPE, uwsgi_fpe);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGPIPE, SIG_IGN);